diff --git a/.htaccess b/.htaccess index 9f88ff4..240960a 100644 --- a/.htaccess +++ b/.htaccess @@ -48,11 +48,11 @@ Options none # malicious users to use up resources. # -php_value upload_max_filesize 16M -php_value post_max_size 16M -php_value memory_limit 16M +php_value upload_max_filesize 32M +php_value post_max_size 32M +php_value memory_limit 32M php_value max_input_time -1 -php_value max_execution_time 60 +php_value max_execution_time 90 # diff --git a/config/dmsDefaults.php b/config/dmsDefaults.php index d55b877..89ddc93 100644 --- a/config/dmsDefaults.php +++ b/config/dmsDefaults.php @@ -412,6 +412,9 @@ require_once(KT_LIB_DIR . '/session/Session.inc'); require_once(KT_LIB_DIR . '/session/control.inc'); require_once(KT_LIB_DIR . '/plugins/pluginutil.inc.php'); -KTPluginUtil::loadPlugins(); + +if ($checkup !== true) { + KTPluginUtil::loadPlugins(); +} ?> diff --git a/config/tableMappings.inc b/config/tableMappings.inc index dca3aa2..9d66533 100644 --- a/config/tableMappings.inc +++ b/config/tableMappings.inc @@ -144,4 +144,6 @@ $default->authentication_sources_table = "authentication_sources"; $default->dashlet_disable_table = "dashlet_disables"; $default->role_allocations_table = "role_allocations"; $default->plugins_table = "plugins"; +$default->document_metadata_version_table = "document_metadata_version"; +$default->document_content_version_table = "document_content_version"; ?> diff --git a/docs/VERSION.txt b/docs/VERSION.txt index 6132c4d..da35147 100644 --- a/docs/VERSION.txt +++ b/docs/VERSION.txt @@ -1 +1 @@ -2.99.6-20050113-1 +2.99.6-20050120-8 diff --git a/edit.php b/edit.php index 761a71c..974eeeb 100644 --- a/edit.php +++ b/edit.php @@ -133,7 +133,7 @@ class KTEditDocumentDispatcher extends KTStandardDispatcher { $document_data["document"] =& $this->oDocument; // we want to grab all the md for this doc, since its faster that way. - $mdlist =& DocumentFieldLink::getList(array('document_id = ?', array($document_id))); + $mdlist =& DocumentFieldLink::getByDocument($document_id); $field_values = array(); foreach ($mdlist as $oFieldLink) { @@ -199,7 +199,7 @@ class KTEditDocumentDispatcher extends KTStandardDispatcher { // erk. we need all the items that the document _does_ need, _and_ what they have, // _and_ what they don't ... // we want to grab all the md for this doc, since its faster that way. - $current_md =& DocumentFieldLink::getList(array('document_id = ?', array($document_id))); + $current_md =& DocumentFieldLink::getByDocument($document_id); // to get all fields, we merge repeatedly from KTFieldset::get @@ -257,7 +257,7 @@ class KTEditDocumentDispatcher extends KTStandardDispatcher { //return '
' . print_r($field_values, true) . '
'; $this->startTransaction(); - $res = KTDocumentUtil::createMetadataVersion($oDocument); + $oDocument->startNewMetadataVersion(); if (PEAR::isError($res)) { $this->errorRedirectToMain('Unable to create a metadata version of the document.'); } @@ -265,7 +265,6 @@ class KTEditDocumentDispatcher extends KTStandardDispatcher { $oDocument->setName($title); $oDocument->setLastModifiedDate(getCurrentDateTime()); $oDocument->setModifiedUserId($this->oUser->getId()); - $oDocument->setMetadataVersion($oDocument->getMetadataVersion() + 1); $oDocumentTransaction = & new DocumentTransaction($oDocument, 'update metadata.', 'ktcore.transactions.update'); $res = $oDocumentTransaction->create(); @@ -280,6 +279,8 @@ class KTEditDocumentDispatcher extends KTStandardDispatcher { $res = KTDocumentUtil::saveMetadata($oDocument, $field_values); if (PEAR::isError($res)) { + var_dump($res); + exit(0); $this->rollbackTransaction(); // right. we're rolled out. now we want to regenerate the page, + errors. diff --git a/lib/browse/DocumentCollection.inc.php b/lib/browse/DocumentCollection.inc.php index bceeb50..ad161df 100644 --- a/lib/browse/DocumentCollection.inc.php +++ b/lib/browse/DocumentCollection.inc.php @@ -57,7 +57,7 @@ class DocumentCollection { // FIXME affect the column based on this. // defaults - $this->_sDocumentSortField = "D.name"; + $this->_sDocumentSortField = "DM.name"; $this->_sFolderSortField = "F.name"; // then we start. @@ -145,9 +145,7 @@ class DocumentCollection { $this->activeset = array( "folders" => $folderSet, "documents" => $documentSet, - ); - - + ); } // stub: fetch all relevant information about a document (that will reasonably be fetched). diff --git a/lib/browse/PartialQuery.inc.php b/lib/browse/PartialQuery.inc.php index a1ee65f..bfa6995 100644 --- a/lib/browse/PartialQuery.inc.php +++ b/lib/browse/PartialQuery.inc.php @@ -11,6 +11,7 @@ require_once(KT_LIB_DIR . "/util/ktutil.inc"); require_once(KT_LIB_DIR . "/database/dbutil.inc"); +require_once(KT_LIB_DIR . "/search/searchutil.inc.php"); // Abstract base class. class PartialQuery { @@ -80,7 +81,14 @@ class BrowseQuery extends PartialQuery{ $sSelect = KTUtil::arrayGet($aOptions, 'select', 'D.id'); - $sQuery = "SELECT $sSelect FROM " . KTUtil::getTableName("documents") . " AS D $sPermissionJoin $sWhere "; + $sQuery = sprintf("SELECT %s FROM %s AS D + LEFT JOIN %s AS DM ON D.metadata_version_id = DM.id + LEFT JOIN %s AS DC ON DM.content_version_id = DC.id + %s %s", + $sSelect, KTUtil::getTableName("documents"), + KTUtil::getTableName("document_metadata_version"), + KTUtil::getTableName("document_content_version"), + $sPermissionJoin, $sWhere); $aParams = array(); $aParams = array_merge($aParams, $aPermissionParams); $aParams[] = $this->folder_id; diff --git a/lib/database/dbutil.inc b/lib/database/dbutil.inc index 12573ad..9cddbef 100644 --- a/lib/database/dbutil.inc +++ b/lib/database/dbutil.inc @@ -50,7 +50,9 @@ class DBUtil { $sQuery = $query; } $res = $db->query($sQuery, $aParams); - $default->queryLog->debug('Query: ' . DBUtil::lastQuery($db)); + if ($default->queryLog) { + $default->queryLog->debug('Query: ' . DBUtil::lastQuery($db)); + } return $res; } diff --git a/lib/documentmanagement/Document.inc b/lib/documentmanagement/Document.inc index 038f568..98a4569 100644 --- a/lib/documentmanagement/Document.inc +++ b/lib/documentmanagement/Document.inc @@ -19,190 +19,98 @@ DEFINE("STATUS_VERSION", 6); require_once(KT_LIB_DIR . "/foldermanagement/Folder.inc"); -class Document extends KTEntity { - var $_bUsePearError = true; - - // {{{ attributes - /** primary key */ +require_once(KT_LIB_DIR . '/documentmanagement/documentcontentversion.inc.php'); +require_once(KT_LIB_DIR . '/documentmanagement/documentcore.inc.php'); +require_once(KT_LIB_DIR . '/documentmanagement/documentmetadataversion.inc.php'); + +class Document { var $iId; - /** document type primary key */ - var $iDocumentTypeID; - - /** document name */ - var $sName; - - /** document file name (path to document on file system) */ - var $sFileName; - - /** document file size */ - var $iSize; - - /** primary key of user who created document */ - var $iCreatorID; - - /** date the document was last modified */ - var $dModified; - - /** file description */ - var $sDescription; - - /** primary key of file mime type */ - var $iMimeTypeID; + var $_oDocumentCore = null; + var $_oDocumentContentVersion = null; + var $_oDocumentMetadataVersion = null; + - /** primary key of folder under which document is stored */ - var $iFolderID; + // {{{ getters/setters - /** major revision number */ - var $iMajorVersion; + // locally stored info. - /** minor revision number */ - var $iMinorVersion; - - /** document checked out status */ - var $bIsCheckedOut; - //?? make checked out a status? - - /** document status **/ - var $iStatusID; - - /** the user that currently has the document checked out */ - var $iCheckedOutUserID; - - /** comma delimited string of folder hierarch this document falls under */ - var $sParentFolderIDs; - - /** forward slash deliminated path from repository root */ - var $sFullPath; - - /** date the document was created */ - var $dCreated; - - /** object which controls (read/write) permissions on this document */ - var $iPermissionObjectID; - - /** object which has quick lookups (read-only) on permissions on this document */ - var $iPermissionLookupID; + function getId() { return $this->iId; } + + // Document Core + + function getFolderID() { return $this->_oDocumentCore->getFolderId(); } + function setFolderID($iNewValue) { $this->_oDocumentCore->setFolderId($iNewValue); } + + function getCreatorID() { return $this->_oDocumentCore->getCreatorId(); } + function setCreatorID($iNewValue) { $this->_oDocumentCore->setCreatorId($iNewValue); } + + function getLastModifiedDate() { return $this->_oDocumentCore->getLastModifiedDate(); } + function setLastModifiedDate($dNewValue) { $this->_oDocumentCore->setLastModifiedDate($dNewValue); } + + function getCreatedDateTime() { return $this->_oDocumentCore->getCreatedDateTime(); } + + function getIsCheckedOut() { return $this->_oDocumentCore->getIsCheckedOut(); } + function setIsCheckedOut($bNewValue) { $this->_oDocumentCore->setIsCheckedOut(KTUtil::anyToBool($bNewValue)); } + + function getCheckedOutUserID() { return $this->_oDocumentCore->getCheckedOutUserId(); } + function setCheckedOutUserID($iNewValue) { $this->_oDocumentCore->setCheckedOutUserId($iNewValue); } + + function getPermissionObjectID() { return $this->_oDocumentCore->getPermissionObjectId(); } + function setPermissionObjectID($iNewValue) { $this->_oDocumentCore->setPermissionObjectId($iNewValue); } + + function getPermissionLookupID() { return $this->_oDocumentCore->getPermissionLookupId(); } + function setPermissionLookupID($iNewValue) { $this->_oDocumentCore->setPermissionLookupId($iNewValue); } + + function getModifiedUserId() { return $this->_oDocumentCore->getModifiedUserId(); } + function setModifiedUserId($iNewValue) { $this->_oDocumentCore->setModifiedUserId($iNewValue); } + + // Document Metadata Items + + function getDocumentTypeID() { return $this->_oDocumentMetadataVersion->getDocumentTypeId(); } + function setDocumentTypeID($sNewValue) { $this->_oDocumentMetadataVersion->setDocumentTypeId($sNewValue); } + + function getName() { return $this->_oDocumentMetadataVersion->getName(); } + function setName($sNewValue) { $this->_oDocumentMetadataVersion->setName($sNewValue); } - /** if this is a historic version, a pointer to the live document */ - var $iLiveDocumentID = null; + function getDescription() { return $this->_oDocumentMetadataVersion->getDescription(); } + function setDescription($sNewValue) { $this->_oDocumentMetadataVersion->setDescription($sNewValue); } + + function getStatusID() { return $this->_oDocumentCore->getStatusId(); } + function setStatusID($iNewValue) { $this->_oDocumentMetadataVersion->setStatusId($iNewValue); $this->_oDocumentCore->setStatusId($iNewValue); } + + function getMetadataVersion() { return $this->_oDocumentMetadataVersion->getMetadataVersion(); } + function setMetadataVersion($iNewValue) { $this->_oDocumentMetadataVersion->getMetadataVersion($iNewValue); } - /** metadata revision number */ - var $iMetadataVersion; + function getMetadataVersionId() { return $this->_oDocumentCore->getMetadataVersionId(); } + function setMetadataVersionId($iNewValue) { $this->_oDocumentCore->setMetadataVersionId($iNewValue); } - /** storage path to the file from the repository root */ - var $sStoragePath; - - // }}} + function getContentVersionId() { return $this->_oDocumentMetadataVersion->getContentVersionId(); } + function setContentVersionId($iNewValue) { $this->_oDocumentMetadataVersion->setContentVersionId($iNewValue); } - // {{{ KTEntity stuff - var $_aFieldToSelect = array( - "iId" => "id", - "iDocumentTypeID" => 'document_type_id', - "sName" => 'name', - "sFileName" => 'filename', - "iSize" => 'size', - "iCreatorID" => 'creator_id', - "dModified" => 'modified', - "sDescription" => 'description', - "iMimeTypeID" => 'mime_id', - "iFolderID" => 'folder_id', - "iMajorVersion" => 'major_version', - "iMinorVersion" => 'minor_version', - "bIsCheckedOut" => 'is_checked_out', - "iCheckedOutUserID" => 'checked_out_user_id', - "sParentFolderIDs" => 'parent_folder_ids', - "sFullPath" => 'full_path', - "iStatusID" => 'status_id', - "dCreated" => 'created', - "iPermissionObjectID" => 'permission_object_id', - "iPermissionLookupID" => 'permission_lookup_id', - "iLiveDocumentID" => 'live_document_id', - "iMetadataVersion" => 'metadata_version', - "sStoragePath" => 'storage_path', - "iModifiedUserId" => 'modified_user_id', - ); - // }}} - - // {{{ constructor - /** - * Document class constructor - * - * @param $sName File Name - * @param $iSize File size in bytes - * @param $iCreatorID Primary key of user who created document - * @param $sDescription Description - * @param $iMimeID Primary key of file mime type - * @param $iFolderID Primary key of folder to which document belongs - * - */ - function Document($sNewName = null, $sNewFileName = null, $iNewSize = null, $iNewCreatorID = null, $iNewMimeID = null, $iNewFolderID = null, $sNewDescription = "None") { - $this->iId = -1; //primary key not set as document is not stored yet - $this->sName = $sNewName; - $this->iSize = $iNewSize; - $this->iCreatorID = $iNewCreatorID; - $this->sFileName = $sNewFileName; - $this->sDescription = $sNewDescription; - $this->iMimeTypeID = $iNewMimeID; - $this->iFolderID = $iNewFolderID; - if (!empty($this->iFolderID)) { - $this->iDocumentTypeID = Folder::getDefaultFolderDocumentType($this->iFolderID); - } - $this->iMajorVersion = 0; - $this->iMetadataVersion = 0; - $this->iMinorVersion = 1; - $this->bIsCheckedOut = false; - $this->iCheckedOutUserID = -1; - // FIXME: statuses - $this->iStatusID = LIVE; - } - // }}} + // Document Content Version + + function getFileName() { return $this->_oDocumentContentVersion->getFileName(); } + function setFileName($sNewValue) { $this->_oDocumentContentVersion->setFileName($sNewValue); } + + function getFileSize() { return $this->_oDocumentContentVersion->getSize(); } + function setFileSize($iNewValue) { $this->_oDocumentContentVersion->setSize($iNewValue); } + + function getSize() { return $this->_oDocumentContentVersion->getSize(); } + function setSize($iNewValue) { $this->_oDocumentContentVersion->setSize($iNewValue); } + + function getMimeTypeID() { return $this->_oDocumentContentVersion->getMimeTypeId(); } + function setMimeTypeID($iNewValue) { $this->_oDocumentContentVersion->setMimeTypeId($iNewValue); } + + function getMajorVersionNumber() { return $this->_oDocumentContentVersion->getMajorVersionNumber(); } + function setMajorVersionNumber($iNewValue) { $this->_oDocumentContentVersion->setMajorVersionNumber($iNewValue); } + + function getMinorVersionNumber() { return $this->_oDocumentContentVersion->getMinorVersionNumber(); } + function setMinorVersionNumber($iNewValue) { $this->_oDocumentContentVersion->setMinorVersionNumber($iNewValue); } - // {{{ getters/setters - function getID() { return $this->iId; } - function getDocumentTypeID() { return $this->iDocumentTypeID; } - function setDocumentTypeID($sNewValue) { $this->iDocumentTypeID = $sNewValue; } - function getName() { return $this->sName; } - function setName($sNewValue) { $this->sName = $sNewValue; } - function getFileName() { return $this->sFileName; } - function setFileName($sNewValue) { $this->sFileName = $sNewValue; } - function getFolderID() { return $this->iFolderID; } - function setFolderID($iNewValue) { $this->iFolderID = $iNewValue; } - function getFileSize() { return $this->iSize; } - function setFileSize($iNewValue) { $this->iSize = $iNewValue; } - function getSize() { return $this->iSize; } - function setSize($iNewValue) { $this->iSize = $iNewValue; } - function getCreatorID() { return $this->iCreatorID; } - function setCreatorID($iNewValue) { $this->iCreatorID = $iNewValue; } - function getLastModifiedDate() { return $this->dModified; } - function setLastModifiedDate($dNewValue) { $this->dModified = $dNewValue; } - function getCreatedDateTime() { return $this->dCreated; } - function getDescription() { return $this->sDescription; } - function setDescription($sNewValue) { $this->sDescription = $sNewValue; } - function getMimeTypeID() { return $this->iMimeTypeID; } - function setMimeTypeID($iNewValue) { $this->iMimeTypeID = $iNewValue; } - function getMajorVersionNumber() { return $this->iMajorVersion; } - function setMajorVersionNumber($iNewValue) { $this->iMajorVersion = $iNewValue; } - function getMinorVersionNumber() { return $this->iMinorVersion; } - function setMinorVersionNumber($iNewValue) { $this->iMinorVersion = $iNewValue; } - function getIsCheckedOut() { return $this->bIsCheckedOut; } - function setIsCheckedOut($bNewValue) { $this->bIsCheckedOut = KTUtil::anyToBool($bNewValue); } - function getCheckedOutUserID() { return $this->iCheckedOutUserID; } - function setCheckedOutUserID($iNewValue) { $this->iCheckedOutUserID = $iNewValue; } - function getStatusID() { return $this->iStatusID; } - function setStatusID($iNewValue) { $this->iStatusID = $iNewValue; } - function getPermissionObjectID() { return $this->iPermissionObjectID; } - function setPermissionObjectID($iNewValue) { $this->iPermissionObjectID = $iNewValue; } - function getPermissionLookupID() { return $this->iPermissionLookupID; } - function setPermissionLookupID($iNewValue) { $this->iPermissionLookupID = $iNewValue; } - function getLiveDocumentID() { return $this->iLiveDocumentID; } - function setLiveDocumentID($iNewValue) { $this->iLiveDocumentID = $iNewValue; } - function getMetadataVersion() { return $this->iMetadataVersion; } - function setMetadataVersion($iNewValue) { $this->iMetadataVersion = $iNewValue; } - function getStoragePath() { return $this->sStoragePath; } - function setStoragePath($sNewValue) { $this->sStoragePath = $sNewValue; } - function getModifiedUserId() { return $this->iModifiedUserId; } - function setModifiedUserId($iNewValue) { $this->iModifiedUserId = $iNewValue; } + function getStoragePath() { return $this->_oDocumentContentVersion->getStoragePath(); } + function setStoragePath($sNewValue) { $this->_oDocumentContentVersion->setStoragePath($sNewValue); } + // }}} // {{{ getParentID @@ -218,7 +126,7 @@ class Document extends KTEntity { // {{{ getVersion /** returns the complete version number as a string */ function getVersion() { - return $this->iMajorVersion . "." . $this->iMinorVersion; + return $this->getMajorVersion() . "." . $this->getMinorVersion(); } // }}} @@ -236,164 +144,69 @@ class Document extends KTEntity { } // }}} - // {{{ ktentity requirements - function _fieldValues () { - $this->sFullPath = Document::_generateFolderPath($this->iFolderID); - $this->sParentFolderIDs = Document::_generateFolderIDs($this->iFolderID); - return array( - 'document_type_id' => $this->iDocumentTypeID, - 'name' => $this->sName, - 'filename' => $this->sFileName, - 'size' => $this->iSize, - 'creator_id' => $this->iCreatorID, - 'modified' => $this->dModified, - 'description' => $this->sDescription, - 'mime_id' => $this->iMimeTypeID, - 'folder_id' => $this->iFolderID, - 'major_version' => $this->iMajorVersion, - 'minor_version' => $this->iMinorVersion, - 'is_checked_out' => KTUtil::anyToBool($this->bIsCheckedOut), - 'checked_out_user_id' => $this->iCheckedOutUserID, - 'parent_folder_ids' => $this->sParentFolderIDs, - 'full_path' => $this->sFullPath, - 'status_id' => $this->iStatusID, - 'created' => $this->dCreated, - 'permission_object_id' => $this->iPermissionObjectID, - 'permission_lookup_id' => $this->iPermissionLookupID, - 'live_document_id' => $this->iLiveDocumentID, - 'metadata_version' => $this->iMetadataVersion, - 'storage_path' => $this->sStoragePath, - 'modified_user_id' => $this->iModifiedUserId, - ); - } - - function _table () { - global $default; - return $default->documents_table; - } - - /** - * Recursive function to generate a comma delimited string containing - * the parent folder ids - * - * @return String comma delimited string containing the parent folder ids - */ - function _generateParentFolderIDS($iFolderID) { - global $default; - //if the folder is not the root folder - if ($iFolderID != 0) { - $sql = $default->db; - $sql->query(array("SELECT parent_id FROM $default->folders_table WHERE ID = ?", $iFolderID));/*ok*/ - $sql->next_record(); - return Document::_generateParentFolderIDS($sql->f("parent_id")) . ",$iFolderID"; - } - return; - } - /** - * Returns a comma delimited string containing the parent folder ids, strips leading / - * - * @return String comma delimited string containing the parent folder ids - */ - function _generateFolderIDs($iFolderID) { - $sFolderIDs = Document::_generateParentFolderIDS($iFolderID); - return substr($sFolderIDs, 1, strlen($sFolderIDs)); - } - - /** - * Recursively generates forward slash deliminated string giving full path of document - * from file system root url - */ - function _generateFullFolderPath($iFolderID) { - global $default; - //if the folder is not the root folder - if ($iFolderID != 0) { - $sql = $default->db; - $sql->query(array("SELECT name, parent_id FROM $default->folders_table WHERE ID = ?", $iFolderID));/*ok*/ - $sql->next_record(); - return Document::_generateFullFolderPath($sql->f("parent_id")) . "/" . $sql->f("name"); - } - return; - } - - /** - * Returns a forward slash deliminated string giving full path of document, strips leading / - */ - function _generateFolderPath($iFolderID) { - global $default; - $sPath = Document::_generateFullFolderPath($iFolderID); - $sPath = substr($sPath, 1, strlen($sPath)); - $sPath = addslashes($sPath); - return $sPath; - } - // }}} - - // {{{ create - /** - * Insert the current document into the database - * - * @return boolean true on successful insert, false otherwise - */ - function create() { - if (empty($this->dCreated)) { - $this->dCreated = getCurrentDateTime(); - } - if (empty($this->dModified)) { - $this->dModified = getCurrentDateTime(); - } - if (empty($this->iModifiedUserId)) { - $this->iModifiedUserId = $this->iCreatorID; - } - $oFolder = Folder::get($this->getFolderID()); - $this->iPermissionObjectID = $oFolder->getPermissionObjectID(); - $res = parent::create(); - - if ($res === true) { - KTPermissionUtil::updatePermissionLookup($this); - } + // {{{ update + function update($bPathMove = false) { + $res = $this->_oDocumentCore->update(); + if (PEAR::isError($res)) { var_dump($res); return $res; } + + $res = $this->_oDocumentContentVersion->update(); + if (PEAR::isError($res)) { var_dump($res); return $res; } + + $res = $this->_oDocumentMetadataVersion->update(); + if (PEAR::isError($res)) { var_dump($res); return $res; } return $res; } // }}} - // {{{ update - function update($bPathMove = false) { - $res = parent::update(); - if (($res === true) && ($bPathMove === true)) { - KTPermissionUtil::updatePermissionLookup($this); + // {{{ get + function &get($iId, $iMetadataVersion=null) { + $oDocument = new Document(); + if (!is_numeric($iId)) { print "
Document.inc: 162: "; var_dump($iId); print "
"; } + $res = $oDocument->load($iId, $iMetadataVersion); + if (PEAR::isError($res)) { + return $res; } - return $res; + return $oDocument; } // }}} - // {{{ get - function &get($iId) { - return KTEntityUtil::get('Document', $iId); + function load($iId, $iMetadataVersionId = null) { + $this->iId = $iId; + $this->_oDocumentCore = KTDocumentCore::get($iId); + if (PEAR::isError($this->_oDocumentCore)) { return $this->_oDocumentCore; } + + // FIXME add error $res if MDV > $_oDC->getMDV + if (is_null($iMetadataVersionId)) { + $this->_oDocumentMetadataVersion = KTDocumentMetadataVersion::get($this->_oDocumentCore->getMetadataVersionId()); + } else { + $this->_oDocumentMetadataVersion = KTDocumentMetadataVersion::get($iMetadataVersionId); + } + if (PEAR::isError($this->_oDocumentMetadataVersion)) { var_dump($this->_oDocumentMetadataVersion); return $this->_oDocumentMetadataVersion; } + + $this->_oDocumentContentVersion = KTDocumentContentVersion::get($this->_oDocumentMetadataVersion->getContentVersionId()); + if (PEAR::isError($this->_oDocumentContentVersion)) { return $this->_oDocumentContentVersion; } } - // }}} // {{{ getList /** * Static function - * Get a list of Documents + * Get a list of Documents - CAN ONLY USE KTDOCUMENTCORE QUERIES * * @param String Where clause (not required) * * @return Array array of Documents objects, false otherwise. */ function getList($sWhereClause = null) { - return KTEntityUtil::getList(Document::_table(), 'Document', $sWhereClause); - } - // }}} + $aOptions = array('ids' => true); + $aIds = KTDocumentCore::getList($sWhereClause, $aOptions); + $aList = array(); + foreach($aIds as $iId) { + $aList[] = Document::get($iId); + }; + return $aList; - // {{{ getPath - /** - * Get the full path for a document - * - * @return string full path of document - */ - function getPath() { - return Folder::getFolderPath($this->iFolderID) . $this->sFileName; } // }}} @@ -404,10 +217,10 @@ class Document extends KTEntity { * @return string full path to document */ function getDisplayPath($bDisplayIcon = false) { - $sFolderPath = Folder::getFolderDisplayPath($this->iFolderID); + $sFolderPath = Folder::getFolderDisplayPath($this->getFolderID()); // #3425 for consistency return ($bDisplayIcon ? $this->getIcon() : "") . - ($sFolderPath == "" ? "Deleted Folder" : $sFolderPath) . " » " . $this->sFileName; + ($sFolderPath == "" ? "Deleted Folder" : $sFolderPath) . " » " . $this->getName(); } // }}} @@ -422,6 +235,9 @@ class Document extends KTEntity { * @return boolean true if document exists, false otherwise. */ function documentExists($sFileName, $iFolderID) { + return false; + + global $default; $sql = $default->db; $sQuery = "SELECT * FROM $default->documents_table " ./*ok*/ @@ -446,7 +262,6 @@ class Document extends KTEntity { * @return string full path to document */ function getDocumentDisplayPath($iDocumentID) { - global $default; $oDocument = & Document::get($iDocumentID); return $oDocument->getDisplayPath(); } @@ -466,21 +281,18 @@ class Document extends KTEntity { } // }}} - // {{{ getByLiveDocument - function &getByLiveDocument($oDocument) { - return KTEntityUtil::getByDict('Document', array( - 'live_document_id' => $oDocument->getID(), - ), array('multi' => true, 'orderby' => 'modified DESC')); - } - // }}} - // {{{ getByFolderIDAndLookupID function &getByFolderIDAndLookupID($iParentID, $iLookupID, $aOptions = null) { - return KTEntityUtil::getByDict('Document', array( + $aIds = KTEntityUtil::getByDict('KTDocumentCore', array( 'folder_id' => $iParentID, 'permission_lookup_id' => $iLookupID, 'status_id' => LIVE, - ), array('multi' => true)); + ), array('multi' => true, 'ids' => true)); + + $aList = array(); + foreach ($aIds as $iId) { + $aList[] = Document::get($iId); + } } // }}} @@ -492,8 +304,112 @@ class Document extends KTEntity { if (KTUtil::arrayGet($aOptions, "mimetypeid") === null) { $aOptions['mimetypeid'] = 0; } - return KTEntityUtil::createFromArray('Document', $aOptions); + $oDocument = new Document(); + $aOptions = array_change_key_case($aOptions); + + $aCoreKeys = array( + "CreatorId", + "Created", + "ModifiedUserId", + "Modified", + "FolderId", + "StatusId", + ); + + $aCore = array(); + foreach ($aCoreKeys as $sKey) { + $sKey = strtolower($sKey); + $sValue = KTUtil::arrayGet($aOptions, $sKey); + if (!is_null($sValue)) { + $aCore[$sKey] = $sValue; + } + } + + $aMetadataVersionKeys = array( + "MetadataVersion", + "ContentVersionId", + "DocumentTypeId", + "Name", + "Description", + "StatusId", + "VersionCreated", + "VersionCreatorId", + ); + + $aMetadataVersion = array(); + foreach ($aMetadataVersionKeys as $sKey) { + $sKey = strtolower($sKey); + $sValue = KTUtil::arrayGet($aOptions, $sKey); + if (!is_null($sValue)) { + $aMetadataVersion[$sKey] = $sValue; + } + } + $aMetadataVersion['VersionCreatorId'] = $aCore['creatorid']; + + $aContentKeys = array( + "Filename", + "Size", + "MimeId", + "MajorVersion", + "MinorVersion", + "StoragePath", + ); + + $aContentVersion = array(); + foreach ($aContentKeys as $sKey) { + $sKey = strtolower($sKey); + $sValue = KTUtil::arrayGet($aOptions, $sKey); + if (!is_null($sValue)) { + $aContentVersion[$sKey] = $sValue; + } + } + + $oDocument->_oDocumentCore = KTDocumentCore::createFromArray($aCore); + if (PEAR::isError($oDocument->_oDocumentCore)) { + return $oDocument->_oDocumentCore; + } + $iId = $oDocument->_oDocumentCore->getId(); + $aContentVersion["documentid"] = $iId; + $oDocument->_oDocumentContentVersion = KTDocumentContentVersion::createFromArray($aContentVersion); + if (PEAR::isError($oDocument->_oDocumentContentVersion)) { return $oDocument->_oDocumentContentVersion; } + $aMetadataVersion["documentid"] = $iId; + $aMetadataVersion["contentversionid"] = $oDocument->_oDocumentContentVersion->getId(); + $oDocument->_oDocumentMetadataVersion = KTDocumentMetadataVersion::createFromArray($aMetadataVersion); + if (PEAR::isError($oDocument->_oDocumentMetadataVersion)) { return $oDocument->_oDocumentMetadataVersion; } + $oDocument->_oDocumentCore->setMetadataVersionId($oDocument->_oDocumentMetadataVersion->getId()); + $res = $oDocument->_oDocumentCore->update(); + if (PEAR::isError($res)) { + return $res; + } + $oDocument->iId = $iId; + return $oDocument; + } + + function startNewMetadataVersion() { + $this->_oDocumentMetadataVersion->iId = -1; + $this->_oDocumentMetadataVersion->iMetadataVersion++; + $this->_oDocumentMetadataVersion->create(); + $this->_oDocumentCore->iMetadataVersion = $this->_oDocumentMetadataVersion->iMetadataVersion; + $this->_oDocumentCore->iMetadataVersionId = $this->_oDocumentMetadataVersion->iId; } + function startNewContentVersion() { + $this->_oDocumentContentVersion->iId = -1; + $res = $this->_oDocumentContentVersion->create(); + if (PEAR::isError($res)) { + var_dump($res); + return $res; + } + $this->_oDocumentMetadataVersion->iId = -1; + $this->_oDocumentMetadataVersion->iMetadataVersion++; + $this->_oDocumentMetadataVersion->iContentVersionId = $this->_oDocumentContentVersion->getId(); + $res = $this->_oDocumentMetadataVersion->create(); + if (PEAR::isError($res)) { + var_dump($res); + return $res; + } + $this->_oDocumentCore->iMetadataVersion = $this->_oDocumentMetadataVersion->iMetadataVersion; + $this->_oDocumentCore->iMetadataVersionId = $this->_oDocumentMetadataVersion->iId; + } } ?> diff --git a/lib/documentmanagement/DocumentFieldLink.inc b/lib/documentmanagement/DocumentFieldLink.inc index 12c70dc..f910948 100644 --- a/lib/documentmanagement/DocumentFieldLink.inc +++ b/lib/documentmanagement/DocumentFieldLink.inc @@ -29,7 +29,7 @@ class DocumentFieldLink extends KTEntity { /** document field link primary key */ var $iId; /** primary key of document to which field is linked */ - var $iDocumentId; + var $iMetadataVersionId; /** primary key of field to which document is linked */ var $iDocumentFieldId; /** field value */ @@ -37,7 +37,7 @@ class DocumentFieldLink extends KTEntity { var $_aFieldToSelect = array( 'iId' => 'id', - 'iDocumentId' => 'document_id', + 'iMetadataVersionId' => 'metadata_version_id', 'iDocumentFieldId' => 'document_field_id', 'sValue' => 'value', ); @@ -74,8 +74,8 @@ class DocumentFieldLink extends KTEntity { * @return int document primary key to which the field is linked * */ - function getDocumentId() { - return $this->iDocumentId; + function getMetadataVersionId() { + return $this->iMetadataVersionId; } /** @@ -84,8 +84,8 @@ class DocumentFieldLink extends KTEntity { * @param Document primary key to which field is linked * */ - function setDocumentId($iNewValue) { - $this->iDocumentId = $iNewValue; + function setMetadataVersionId($iNewValue) { + $this->iMetadataVersionId = $iNewValue; } /** @@ -141,17 +141,8 @@ class DocumentFieldLink extends KTEntity { * * @return DocumentFieldLink populated DocumentFieldLink object on success, false otherwise and set $_SESSION["errorMessage"] */ - function & get($iDocumentFieldLinkId) { - global $default, $lang_err_doc_not_exist; - $sql = $default->db; - $sql->query(array("SELECT * FROM " . $default->document_fields_link_table . " WHERE id = ?", $iDocumentFieldLinkId));/*ok*/ - if ($sql->next_record()) { - $oDocumentFieldLink = & new DocumentFieldLink($sql->f("document_id"), $sql->f("document_field_id"), $sql->f("value")); - $oDocumentFieldLink->iId = $iDocumentFieldLinkId; - return $oDocumentFieldLink; - } - $_SESSION["errorMessage"] = $lang_err_object_not_exist . "id = " . $iDocumentId . " table = $default->document_fields_link_table"; - return false; + function &get($iId) { + return KTEntityUtil::get('DocumentFieldLink', $iId); } function &getList($sWhereClause = null) { @@ -160,15 +151,18 @@ class DocumentFieldLink extends KTEntity { function &getByDocument($oDocument) { - $iDocumentId = KTUtil::getId($oDocument); + $oDocument =& KTUtil::getObject('Document', $oDocument); + $iMetadataVersionId = $oDocument->getMetadataVersionId(); return KTEntityUtil::getByDict('DocumentFieldLink', array( - 'document_id' => $iDocumentId, + 'metadata_version_id' => $iMetadataVersionId, ), array('multi' => true)); } function &getByDocumentAndField($oDocument, $oField) { + $oDocument =& KTUtil::getObject('Document', $oDocument); + $iMetadataVersionId = $oDocument->getMetadataVersionId(); return KTEntityUtil::getByDict('DocumentFieldLink', array( - 'document_id' => KTUtil::getId($oDocument), + 'metadata_version_id' => $iMetadataVersionId, 'document_field_id' => KTUtil::getId($oDocument), )); } diff --git a/lib/documentmanagement/DocumentTransaction.inc b/lib/documentmanagement/DocumentTransaction.inc index 8b6cbba..643a264 100644 --- a/lib/documentmanagement/DocumentTransaction.inc +++ b/lib/documentmanagement/DocumentTransaction.inc @@ -61,7 +61,7 @@ class DocumentTransaction { $this->sComment = $sNewComment; $this->sTransactionNS = $sTransactionNS; $this->sVersion = $oDocument->getMajorVersionNumber() . "." . $oDocument->getMinorVersionNumber(); - $oFolder = Folder::get($oDocument->iFolderID); + $oFolder = Folder::get($oDocument->getFolderId()); $this->sFileName = addslashes($oFolder->sFullPath . "/" . $oFolder->getName() . "/" . $oDocument->getName()); $this->iUserID = $_SESSION["userID"]; diff --git a/lib/documentmanagement/documentcontentversion.inc.php b/lib/documentmanagement/documentcontentversion.inc.php index c80029a..3de2b42 100644 --- a/lib/documentmanagement/documentcontentversion.inc.php +++ b/lib/documentmanagement/documentcontentversion.inc.php @@ -9,13 +9,13 @@ class KTDocumentContentVersion extends KTEntity { var $iDocumentId; /** What was the filename of the stored content */ - var $sFilename; + var $sFileName; /** How big was the stored content */ var $iSize; /** Which MIME type was this content */ - var $iMimeId; + var $iMimeTypeId; /** User-specified major version for this content */ var $iMajorVersion; @@ -31,9 +31,9 @@ class KTDocumentContentVersion extends KTEntity { // transaction-related "iDocumentId" => 'document_id', - "sFilename" => 'filename', + "sFileName" => 'filename', "iSize" => 'size', - "iMimeId" => 'mime_id', + "iMimeTypeId" => 'mime_id', "iMajorVersion" => 'major_version', "iMinorVersion" => 'minor_version', "sStoragePath" => 'storage_path', @@ -42,7 +42,48 @@ class KTDocumentContentVersion extends KTEntity { function KTDocumentContentVersion() { } - + function getFileName() { return $this->sFileName; } + function setFileName($sNewValue) { $this->sFileName = $sNewValue; } + function getFileSize() { return $this->iSize; } + function setFileSize($iNewValue) { $this->iSize = $iNewValue; } + function getSize() { return $this->iSize; } + function setSize($iNewValue) { $this->iSize = $iNewValue; } + function getMimeTypeId() { return $this->iMimeTypeId; } + function setMimeTypeId($iNewValue) { $this->iMimeTypeId = $iNewValue; } + function getMajorVersionNumber() { return $this->iMajorVersion; } + function setMajorVersionNumber($iNewValue) { $this->iMajorVersion = $iNewValue; } + function getMinorVersionNumber() { return $this->iMinorVersion; } + function setMinorVersionNumber($iNewValue) { $this->iMinorVersion = $iNewValue; } + function getStoragePath() { return $this->sStoragePath; } + function setStoragePath($sNewValue) { $this->sStoragePath = $sNewValue; } + + function _table() { + return KTUtil::getTableName('document_content_version'); + } + + function &createFromArray($aOptions) { + return KTEntityUtil::createFromArray('KTDocumentContentVersion', $aOptions); + } + + function create() { + if (empty($this->iSize)) { + $this->iSize = 0; + } + if (empty($this->iMimeTypeId)) { + $this->iMimeTypeId = 0; + } + if (empty($this->iMajorVersion)) { + $this->iMajorVersion = 0; + } + if (empty($this->iMinorVersion)) { + $this->iMinorVersion = 1; + } + return parent::create(); + } + + function &get($iId) { + return KTEntityUtil::get('KTDocumentContentVersion', $iId); + } } ?> diff --git a/lib/documentmanagement/documentcore.inc.php b/lib/documentmanagement/documentcore.inc.php index 947c6dd..3a53b26 100644 --- a/lib/documentmanagement/documentcore.inc.php +++ b/lib/documentmanagement/documentcore.inc.php @@ -37,6 +37,11 @@ class KTDocumentCore extends KTEntity { /** The most recent metadata version for the object */ var $iMetadataVersionId; + var $iMetadataVersion; + + var $bIsCheckedOut; + var $iCheckedOutUserId; + var $_aFieldToSelect = array( "iId" => "id", @@ -45,7 +50,8 @@ class KTDocumentCore extends KTEntity { "dCreated" => 'created', "iModifiedUserId" => 'modified_user_id', "dModified" => 'modified', - + "iMetadataVersionId" => 'metadata_version_id', + "iMetadataVersion" => 'metadata_version', // location-related "iFolderId" => 'folder_id', @@ -54,6 +60,8 @@ class KTDocumentCore extends KTEntity { // status "iStatusId" => 'status_id', + "bIsCheckedOut" => 'is_checked_out', + "iCheckedOutUserId" => 'checked_out_user_id', // permission-related "iPermissionObjectId" => 'permission_object_id', @@ -77,11 +85,22 @@ class KTDocumentCore extends KTEntity { function getStatusId() { return $this->iStatusId; } function setStatusId($iNewValue) { $this->iStatusId = $iNewValue; } + function getIsCheckedOut() { return $this->bIsCheckedOut; } + function setIsCheckedOut($bNewValue) { $this->bIsCheckedOut = KTUtil::anyToBool($bNewValue); } + function getCheckedOutUserId() { return $this->iCheckedOutUserId; } + function setCheckedOutUserId($iNewValue) { $this->iCheckedOutUserId = $iNewValue; } function getPermissionObjectId() { return $this->iPermissionObjectId; } function setPermissionObjectId($iNewValue) { $this->iPermissionObjectId = $iNewValue; } function getPermissionLookupId() { return $this->iPermissionLookupId; } function setPermissionLookupId($iNewValue) { $this->iPermissionLookupId = $iNewValue; } + + function getMetadataVersionId() { return $this->iMetadataVersionId; } + function setMetadataVersionId($iNewValue) { $this->iMetadataVersionId = $iNewValue; } + + function getMetadataVersion() { return $this->iMetadataVersion; } + function setMetadataVersion($iNewValue) { $this->iMetadataVersion = $iNewValue; } + // }}} // {{{ getParentId @@ -96,8 +115,8 @@ class KTDocumentCore extends KTEntity { // {{{ ktentity requirements function _fieldValues () { - $this->sFullPath = KTDocument::_generateFolderPath($this->iFolderId); - $this->sParentFolderIds = KTDocument::_generateFolderIds($this->iFolderId); + $this->sFullPath = KTDocumentCore::_generateFolderPath($this->iFolderId); + $this->sParentFolderIds = KTDocumentCore::_generateFolderIds($this->iFolderId); return parent::_fieldValues(); } @@ -116,7 +135,7 @@ class KTDocumentCore extends KTEntity { $sQuery = sprintf('SELECT parent_id FROM %s WHERE id = ?', $sTable); $aParams = array($iFolderId); $iParentId = DBUtil::getOneResultKey(array($sQuery, $aParams), 'parent_id'); - return Document::_generateParentFolderIds($iParentId) . ",$iFolderId"; + return KTDocumentCore::_generateParentFolderIds($iParentId) . ",$iFolderId"; } /** @@ -125,7 +144,7 @@ class KTDocumentCore extends KTEntity { * @return String comma delimited string containing the parent folder ids */ function _generateFolderIds($iFolderId) { - $sFolderIds = Document::_generateParentFolderIds($iFolderId); + $sFolderIds = KTDocumentCore::_generateParentFolderIds($iFolderId); return substr($sFolderIds, 1, strlen($sFolderIds)); } @@ -134,23 +153,22 @@ class KTDocumentCore extends KTEntity { * from file system root url */ function _generateFullFolderPath($iFolderId) { - global $default; //if the folder is not the root folder if (empty($iFolderId)) { return; } + $sTable = KTUtil::getTableName('folders'); $sQuery = sprintf("SELECT name, parent_id FROM %s WHERE Id = ?", $sTable); $aParams = array($iFolderId); $aRow = DBUtil::getOneResult(array($sQuery, $aParams)); - return Document::_generateFullFolderPath($aRow["parent_id"]) . "/" . $aRow["name"]; + return KTDocumentCore::_generateFullFolderPath($aRow["parent_id"]) . "/" . $aRow["name"]; } /** * Returns a forward slash deliminated string giving full path of document, strips leading / */ function _generateFolderPath($iFolderId) { - global $default; - $sPath = Document::_generateFullFolderPath($iFolderId); + $sPath = KTDocumentCore::_generateFullFolderPath($iFolderId); $sPath = substr($sPath, 1, strlen($sPath)); return $sPath; } @@ -167,6 +185,12 @@ class KTDocumentCore extends KTEntity { if (empty($this->iModifiedUserId)) { $this->iModifiedUserId = $this->iCreatorId; } + if (empty($this->iMetadataVersion)) { + $this->iMetadataVersion = 0; + } + if (empty($this->bIsCheckedOut)) { + $this->bIsCheckedOut = false; + } $oFolder = Folder::get($this->getFolderId()); $this->iPermissionObjectId = $oFolder->getPermissionObjectId(); $res = parent::create(); @@ -191,11 +215,36 @@ class KTDocumentCore extends KTEntity { // {{{ get function &get($iId) { - return KTEntityUtil::get('KTDocument', $iId); + return KTEntityUtil::get('KTDocumentCore', $iId); } // }}} + // {{{ getList + function &getList($sWhere = null, $aOptions) { + return KTEntityUtil::getList2('KTDocumentCore', $sWhere, $aOptions); + } + // }}} + // {{{ _table + function _table() { + return KTUtil::getTableName('documents'); + } + // }}} + + // {{{ getPath + /** + * Get the full path for a document + * + * @return string full path of document + */ + function getPath() { + return Folder::getFolderPath($this->iFolderId) . $this->sFileName; + } + // }}} + + function &createFromArray($aOptions) { + return KTEntityUtil::createFromArray('KTDocumentCore', $aOptions); + } } ?> diff --git a/lib/documentmanagement/documentmetadataversion.inc.php b/lib/documentmanagement/documentmetadataversion.inc.php index e7bf630..58dcee3 100644 --- a/lib/documentmanagement/documentmetadataversion.inc.php +++ b/lib/documentmanagement/documentmetadataversion.inc.php @@ -58,19 +58,43 @@ class KTDocumentMetadataVersion extends KTEntity { function setDocumentId($iNewValue) { $this->iDocumentId = $iNewValue; } function getMetadataVersion() { return $this->iMetadataVersion; } function setMetadataVersion($iNewValue) { $this->iMetadataVersion = $iNewValue; } + function getContentVersionId() { return $this->iContentVersionId; } + function setContentVersion($iNewValue) { $this->iContentVersion = $iNewValue; } function getDocumentTypeId() { return $this->iDocumentTypeId; } function setDocumentTypeId($iNewValue) { $this->iDocumentTypeId = $iNewValue; } function getName() { return $this->sName; } function setName($sNewValue) { $this->sName = $sNewValue; } function getDescription() { return $this->sDescription; } function setDescription($sNewValue) { $this->sDescription = $sNewValue; } - function getStatusId() { return $this->sStatusId; } - function setStatusId($iNewValue) { $this->sStatusId = $iNewValue; } + function getStatusId() { return $this->iStatusId; } + function setStatusId($iNewValue) { $this->iStatusId = $iNewValue; } function getVersionCreated() { return $this->dVersionCreated; } function setVersionCreated($dNewValue) { $this->dVersionCreated = $dNewValue; } function getVersionCreatorId() { return $this->iVersionCreatorId; } function setVersionCreatorId($iNewValue) { $this->iVersionCreatorId = $iNewValue; } // }}} + + function &createFromArray($aOptions) { + return KTEntityUtil::createFromArray('KTDocumentMetadataVersion', $aOptions); + } + + function _table() { + return KTUtil::getTableName('document_metadata_version'); + } + + function create() { + if (is_null($this->iMetadataVersion)) { + $this->iMetadataVersion = 0; + } + if (is_null($this->dVersionCreated)) { + $this->dVersionCreated = getCurrentDateTime(); + } + return parent::create(); + } + + function &get($iId) { + return KTEntityUtil::get('KTDocumentMetadataVersion', $iId); + } } ?> diff --git a/lib/documentmanagement/documentutil.inc.php b/lib/documentmanagement/documentutil.inc.php index 9528a7f..216523e 100644 --- a/lib/documentmanagement/documentutil.inc.php +++ b/lib/documentmanagement/documentutil.inc.php @@ -99,19 +99,15 @@ class KTDocumentUtil { } function checkin($oDocument, $sFilename, $sCheckInComment, $oUser) { - $sBackupPath = $oDocument->getPath() . "-" . $oDocument->getMajorVersionNumber() . "." . $oDocument->getMinorVersionNumber(); - $bSuccess = @copy($oDocument->getPath(), $sBackupPath); - if ($bSuccess === false) { - return PEAR::raiseError(_("Unable to backup document prior to upload")); - } - $oVersionedDocument = KTDocumentUtil::createMetadataVersion($oDocument); - if (PEAR::isError($oVersionedDocument)) { - return $oVersionedDocument; - } - $oStorage =& KTStorageManagerUtil::getSingleton(); $iFileSize = filesize($sFilename); + $iPreviousMetadataVersion = $oDocument->getMetadataVersionId(); + + $oDocument->startNewContentVersion(); + + KTDocumentUtil::copyMetadata($oDocument, $iPreviousMetadataVersion); + if (!$oStorage->upload($oDocument, $sFilename)) { // reinstate the backup copy($sBackupPath, $oDocument->getPath()); @@ -120,8 +116,6 @@ class KTDocumentUtil { return PEAR::raiseError(_("An error occurred while storing the new file")); } - $oDocument->setMetadataVersion($oDocument->getMetadataVersion()+1); - $oDocument->setLastModifiedDate(getCurrentDateTime()); $oDocument->setModifiedUserId($oUser->getId()); $oDocument->setIsCheckedOut(false); @@ -201,6 +195,7 @@ class KTDocumentUtil { if (is_null($oContents)) { $res = KTDocumentUtil::setIncomplete($oDocument, "contents"); + var_dump($res); if (PEAR::isError($res)) { $oDocument->delete(); return $res; @@ -287,7 +282,8 @@ class KTDocumentUtil { } $aMetadata = $res; - $res = DBUtil::runQuery(array("DELETE FROM $table WHERE document_id = ?", array($oDocument->getID()))); + $iMetadataVersionId = $oDocument->getMetadataVersionId(); + $res = DBUtil::runQuery(array("DELETE FROM $table WHERE metadata_version_id = ?", array($iMetadataVersionId))); if (PEAR::isError($res)) { return $res; } @@ -298,7 +294,7 @@ class KTDocumentUtil { continue; } $res = DBUtil::autoInsert($table, array( - "document_id" => $oDocument->getID(), + "metadata_version_id" => $iMetadataVersionId, "document_field_id" => $oMetadata->getID(), "value" => $sValue, )); @@ -312,11 +308,22 @@ class KTDocumentUtil { } // }}} + function copyMetadata($oDocument, $iPreviousMetadataVersionId) { + $iNewMetadataVersion = $oDocument->getMetadataVersionId(); + $sTable = KTUtil::getTableName('document_fields_link'); + $aFields = DBUtil::getResultArray(array("SELECT * FROM $sTable WHERE metadata_version_id = ?", array($iPreviousMetadataVersionId))); + foreach ($aFields as $aRow) { + unset($aRow['id']); + $aRow['metadata_version_id'] = $iNewMetadataVersion; + DBUtil::autoInsert($sTable, $aRow); + } + } + // {{{ setIncomplete function setIncomplete(&$oDocument, $reason) { $oDocument->setStatusID(STATUS_INCOMPLETE); $table = "document_incomplete"; - $iId = $oDocument->getID(); + $iId = $oDocument->getId(); $aIncomplete = DBUtil::getOneResult(array("SELECT * FROM $table WHERE id = ?", array($iId))); if (PEAR::isError($aIncomplete)) { return $aIncomplete; diff --git a/lib/metadata/metadatautil.inc.php b/lib/metadata/metadatautil.inc.php index e7182e5..7319692 100644 --- a/lib/metadata/metadatautil.inc.php +++ b/lib/metadata/metadatautil.inc.php @@ -591,15 +591,15 @@ class KTMetadataUtil { function fieldsetsForDocument($oDocument) { global $default; $oDocument = KTUtil::getObject('Document', $oDocument); - $iDocumentId = $oDocument->getId(); + $iMetadataVersionId = $oDocument->getMetadataVersionId(); $iDocumentTypeId = $oDocument->getDocumentTypeId(); $sQuery = "SELECT DISTINCT F.id AS fieldset_id " . - "FROM $default->documents_table AS D INNER JOIN document_fields_link AS DFL ON D.id = DFL.document_id " . + "FROM $default->document_metadata_version_table AS DM INNER JOIN document_fields_link AS DFL ON DM.id = DFL.metadata_version_id " . "INNER JOIN $default->document_fields_table AS DF ON DF.ID = DFL.document_field_id " . "INNER JOIN $default->fieldsets_table AS F ON F.id = DF.parent_fieldset " . - "WHERE D.id = ?"; - $aParam = array($iDocumentId); + "WHERE DM.id = ?"; + $aParam = array($iMetadataVersionId); $aDocumentFieldsetIds = DBUtil::getResultArrayKey(array($sQuery, $aParam), 'fieldset_id'); $aGenericFieldsetIds = KTFieldset::getGenericFieldsets(array('ids' => true)); diff --git a/lib/permissions/permissionutil.inc.php b/lib/permissions/permissionutil.inc.php index c31f505..756803d 100644 --- a/lib/permissions/permissionutil.inc.php +++ b/lib/permissions/permissionutil.inc.php @@ -177,7 +177,32 @@ class KTPermissionUtil { * non-recursively. */ function updatePermissionLookup(&$oFolderOrDocument) { - $oPO = KTPermissionObject::get($oFolderOrDocument->getPermissionObjectID()); + if (!is_a($oFolderOrDocument, 'Folder')) { + if (!is_a($oFolderOrDocument, 'Document')) { + if (!is_a($oFolderOrDocument, 'KTDocumentCore')) { + echo "
";
+                    var_dump($oFolderOrDocument);
+                    echo "
"; + } + } + } + $oChannel =& KTPermissionChannel::getSingleton(); + if (is_a($oFolderOrDocument, 'Folder')) { + $msg = sprintf("Updating folder %s", join("/", $oFolderOrDocument->getPathArray())); + } else { + if (is_a($oFolderOrDocument, 'Document')) { + $msg = sprintf("Updating document %s", $oFolderOrDocument->getName()); + } else { + $msg = sprintf("Updating document %d", $oFolderOrDocument->getId()); + } + } + $oChannel->sendMessage(new KTPermissionGenericMessage($msg)); + + $iPermissionObjectId = $oFolderOrDocument->getPermissionObjectID(); + if (empty($iPermissionObjectId)) { + return; + } + $oPO = KTPermissionObject::get($iPermissionObjectId); $aPAs = KTPermissionAssignment::getByObjectMulti($oPO); $aMapPermAllowed = array(); foreach ($aPAs as $oPA) { @@ -476,4 +501,37 @@ class KTPermissionUtil { // }}} } +class KTPermissionChannel { + var $observers = array(); + + function &getSingleton() { + if (!KTUtil::arrayGet($GLOBALS, 'KT_PermissionChannel')) { + $GLOBALS['KT_PermissionChannel'] = new KTPermissionChannel; + } + return $GLOBALS['KT_PermissionChannel']; + } + + function sendMessage(&$msg) { + foreach ($this->observers as $oObserver) { + $oObserver->receiveMessage($msg); + } + } + + function addObserver(&$obs) { + array_push($this->observers, $obs); + } +} + +class KTPermissionGenericMessage { + function KTPermissionGenericMessage($sMessage) { + $this->sMessage = $sMessage; + } + + function getString() { + return $this->sMessage; + } +} + + + ?> diff --git a/lib/search/searchutil.inc.php b/lib/search/searchutil.inc.php index 7fbcac3..f59857a 100644 --- a/lib/search/searchutil.inc.php +++ b/lib/search/searchutil.inc.php @@ -252,16 +252,20 @@ class KTSearchUtil { } //$sQuery = DBUtil::compactQuery(" - $sQuery = (" + $sQuery = sprintf(" SELECT $sSelect FROM - $default->documents_table AS D + %s AS D + LEFT JOIN %s AS DM ON D.metadata_version_id = DM.id + LEFT JOIN %s AS DC ON DM.content_version_id = DC.id INNER JOIN $default->status_table AS SL on D.status_id=SL.id $sInitialJoin $sCritJoinSQL $sPermissionJoin - $sWhere"); + $sWhere", KTUtil::getTableName('documents'), + KTUtil::getTableName('document_metadata_version'), + KTUtil::getTableName('document_content_version')); // GROUP BY D.id $aParams = array(); diff --git a/lib/storage/ondiskpathstoragemanager.inc.php b/lib/storage/ondiskpathstoragemanager.inc.php index 8caf97f..1bf4559 100644 --- a/lib/storage/ondiskpathstoragemanager.inc.php +++ b/lib/storage/ondiskpathstoragemanager.inc.php @@ -71,7 +71,7 @@ class KTOnDiskPathStorageManager extends KTStorageManager { } function generateStoragePath(&$oDocument) { - $sStoragePath = sprintf("%s/%s", Document::_generateFolderPath($oDocument->getFolderID()), $oDocument->getFileName()); + $sStoragePath = sprintf("%s/%s-%s", KTDocumentCore::_generateFolderPath($oDocument->getFolderID()), $oDocument->getContentVersionId(), $oDocument->getFileName()); return $sStoragePath; } @@ -155,8 +155,8 @@ class KTOnDiskPathStorageManager extends KTStorageManager { global $default; $oConfig =& KTConfig::getSingleton(); - $sCurrentPath = sprintf("%s/%s/%s", $oConfig->get('urls/documentRoot'), Document::_generateFolderPath($oSourceFolder->getID()), $oDocument->getFileName()); - $sDestinationPath = sprintf("%s/%s/%s", $oConfig->get('urls/documentRoot'), Document::_generateFolderPath($oDestinationFolder->getID()), $oDocument->getFileName()); + $sCurrentPath = sprintf("%s/%s/%s", $oConfig->get('urls/documentRoot'), KTDocumentCore::_generateFolderPath($oSourceFolder->getID()), $oDocument->getFileName()); + $sDestinationPath = sprintf("%s/%s/%s", $oConfig->get('urls/documentRoot'), KTDocumentCore::_generateFolderPath($oDestinationFolder->getID()), $oDocument->getFileName()); // find all the previous versions of this document and move them // ie. interrogate transaction history for all CHECKIN transactions and retrieve the versions @@ -191,7 +191,7 @@ class KTOnDiskPathStorageManager extends KTStorageManager { $default->log->error("KTOnDiskPathStorageManager->moveDocument couldn't move $sCurrentPath to $sDestinationPath, documentID=" . $oDocument->getID()); return $res; } - $sStoragePath = sprintf("%s/%s", Document::_generateFolderPath($oDestinationFolder->getID()), $oDocument->getFileName()); + $sStoragePath = sprintf("%s/%s", KTDocumentCore::_generateFolderPath($oDestinationFolder->getID()), $oDocument->getFileName()); $this->setPath($oDocument, $sStoragePath); return true; } diff --git a/lib/upgrades/UpgradeFunctions.inc.php b/lib/upgrades/UpgradeFunctions.inc.php index 7a737c5..d2d7f89 100644 --- a/lib/upgrades/UpgradeFunctions.inc.php +++ b/lib/upgrades/UpgradeFunctions.inc.php @@ -6,6 +6,7 @@ class UpgradeFunctions { "2.0.6" => array("addTemplateMimeTypes"), "2.0.8" => array("setPermissionObject"), "2.99.1" => array("createFieldSets"), + "2.99.7" => array("normaliseDocuments"), #, "createLdapAuthenticationProvider"), ); var $descriptions = array( @@ -14,10 +15,12 @@ class UpgradeFunctions { "addTemplateMimeTypes" => "Add MIME types for Excel and Word templates", "setPermissionObject" => "Set the permission object in charge of a document or folder", "createFieldSets" => "Create a fieldset for each field without one", + "normaliseDocuments" => "Normalise the documents table", ); var $phases = array( "setPermissionObject" => 1, "createFieldSets" => 1, + "normaliseDocuments" => 1, ); // {{{ _setPermissionFolder @@ -265,6 +268,60 @@ class UpgradeFunctions { } } // }}} + + // {{{ normaliseDocuments + function normaliseDocuments() { + $sTable = KTUtil::getTableName('documents'); + DBUtil::runQuery("SET FOREIGN_KEY_CHECKS=0"); + $aDocuments = DBUtil::getResultArray("SELECT * FROM $sTable WHERE metadata_version_id IS NULL"); + foreach ($aDocuments as $aRow) { + print "Document ID: " . $aRow['id']; + $aContentInfo = array( + 'document_id' => $aRow['id'], + 'filename' => $aRow['filename'], + 'size' => $aRow['size'], + 'mime_id' => $aRow['mime_id'], + 'major_version' => $aRow['major_version'], + 'minor_version' => $aRow['minor_version'], + 'storage_path' => $aRow['storage_path'], + ); + $iContentId = DBUtil::autoInsert(KTUtil::getTableName('document_content_version'), $aContentInfo); + print "Content ID: " . $iContentId; + $aMetadataInfo = array( + 'document_id' => $aRow['id'], + 'content_version_id' => $iContentId, + 'document_type_id' => $aRow['document_type_id'], + 'name' => $aRow['name'], + 'description' => $aRow['description'], + 'status_id' => $aRow['status_id'], + 'metadata_version' => $aRow['metadata_version'], + 'version_created' => $aRow['created'], + 'version_creator_id' => $aRow['creator_id'], + ); + $iMetadataId = DBUtil::autoInsert(KTUtil::getTableName('document_metadata_version'), $aMetadataInfo); + print "Metadata ID: " . $iMetadataId; + if (PEAR::isError($iMetadataId)) { + var_dump($iMetadataId); + } + DBUtil::runQuery(array("UPDATE $sTable SET metadata_version_id = ? WHERE id = ?", array($iMetadataId, $aRow['id']))); + print "\n"; + } + DBUtil::runQuery("SET FOREIGN_KEY_CHECKS=1"); + + $aDocumentMap = array(); + $sTable = KTUtil::getTableName('document_fields_link'); + $sDocumentsTable = KTUtil::getTableName('documents'); + $aInfo = DBUtil::getResultArray("SELECT id, document_id, document_field_id, value FROM $sTable WHERE metadata_version_id IS NULL"); + foreach ($aInfo as $aRow) { + $iMetadataVersionId = KTUtil::arrayGet($aDocumentMap, $aRow['document_id']); + if (empty($iMetadataVersionId)) { + $iMetadataVersionId = DBUtil::getOneResultKey(array("SELECT metadata_version_id FROM $sDocumentsTable WHERE id = ?", array($aRow['document_id'])), 'metadata_version_id'); + $aDocumentMap[$aRow['document_id']] = $iMetadataVersionId; + } + DBUtil::runQuery(array("UPDATE $sTable SET metadata_version_id = ? WHERE id = ?", array($iMetadataVersionId, $aRow['id']))); + } + } + // }}} } ?> diff --git a/lib/upgrades/UpgradeItems.inc.php b/lib/upgrades/UpgradeItems.inc.php index 56971b7..45dd00d 100644 --- a/lib/upgrades/UpgradeItems.inc.php +++ b/lib/upgrades/UpgradeItems.inc.php @@ -256,7 +256,7 @@ class SQLUpgradeItem extends UpgradeItem { $phase = 0; return array($fromVersion, $toVersion, $description, $phase); } - $matched = preg_match('#^([\d.]*)/(?:(\d)-)?(.*)\.sql$#', $path, $matches); + $matched = preg_match('#^([\d.]*)/(?:(\d*)-)?(.*)\.sql$#', $path, $matches); if ($matched != 0) { $fromVersion = $matches[1]; $toVersion = $matches[1]; diff --git a/plugins/ktcore/KTFolderActions.php b/plugins/ktcore/KTFolderActions.php index 603c527..9dc0b41 100644 --- a/plugins/ktcore/KTFolderActions.php +++ b/plugins/ktcore/KTFolderActions.php @@ -116,6 +116,7 @@ class KTFolderPermissionsAction extends KTFolderAction { } function do_update() { + require_once(KT_LIB_DIR . "/documentmanagement/observers.inc.php"); $oPO = KTPermissionObject::get($this->oFolder->getPermissionObjectId()); $aFoo = $_REQUEST['foo']; $aPermissions = KTPermission::getList(); @@ -124,9 +125,17 @@ class KTFolderPermissionsAction extends KTFolderAction { $aAllowed = KTUtil::arrayGet($aFoo, $iPermId, array()); KTPermissionUtil::setPermissionForId($oPermission, $oPO, $aAllowed); } + + $po =& new JavascriptObserver($this); + $po->start(); + $oChannel =& KTPermissionChannel::getSingleton(); + $oChannel->addObserver($po); + KTPermissionUtil::updatePermissionLookupForPO($oPO); - return $this->successRedirectToMain(_('Permissions updated'), - array('fFolderId' => $this->oFolder->getId())); + + $this->commitTransaction(); + + $po->redirect(KTUtil::addQueryString($_SERVER['PHP_SELF'], "fFolderId=" . $this->oFolder->getId())); } function do_copyPermissions() { diff --git a/setup/postcheckup.php b/setup/postcheckup.php index 7bc57a3..0b1812d 100644 --- a/setup/postcheckup.php +++ b/setup/postcheckup.php @@ -64,8 +64,8 @@ if ($handle !== false) { Logging support is not currently working. Error is: " . - htmlentities($loggingSupport->toString()) . "

"; + print '

Logging support is not currently working. Error is: ' . + htmlentities($loggingSupport->toString()) . '

'; } else { ?>

Logging support is operational.

diff --git a/setup/upgrade.php b/setup/upgrade.php index 6350259..18fe4ac 100644 --- a/setup/upgrade.php +++ b/setup/upgrade.php @@ -1,5 +1,7 @@ \n"; - $ret .= "DescriptionResult\n"; + print "\n"; + print "\n"; foreach ($upgrades as $upgrade) { $res = $upgrade->performUpgrade(); - $ret .= sprintf('', + printf("\n", htmlspecialchars($upgrade->getDescription()), htmlspecialchars(showResult($res))); } - $ret .= '
DescriptionResult
%s%s
%s%s
'; + print ''; return $ret; } if ($_REQUEST["go"] === "Upgrade") { $performingUpgrade = true; - $upgradeTable = performAllUpgrades(); } else { $upgradeTable = generateUpgradeTable(); } @@ -81,7 +82,6 @@ td { vertical-align: top; } The table below describes the upgrades that need to occur to @@ -93,6 +93,8 @@ if ($upgradeTable) {

The table below describes the upgrades that have occurred to upgrade your KnowledgeTree installation to $default->systemVersion. "; + + $upgradeTable = performAllUpgrades(); } print $upgradeTable; @@ -102,9 +104,6 @@ if ($upgradeTable) { } else { print '

'; } -} else { - -} ?> diff --git a/sql/mysql/install/data.sql b/sql/mysql/install/data.sql index b501f70..b45cb24 100644 --- a/sql/mysql/install/data.sql +++ b/sql/mysql/install/data.sql @@ -1,9 +1,9 @@ -- phpMyAdmin SQL Dump --- version 2.6.4-pl4-Debian-1 +-- version 2.7.0-pl2-Debian-1 -- http://www.phpmyadmin.net -- -- Host: localhost --- Generation Time: Dec 15, 2005 at 06:22 PM +-- Generation Time: Jan 20, 2006 at 05:07 PM -- Server version: 4.1.15 -- PHP Version: 4.4.0-3 @@ -40,16 +40,6 @@ INSERT INTO `archiving_type_lookup` VALUES (2, 'Utilisation'); -- --- Dumping data for table `browse_criteria` --- - -INSERT INTO `browse_criteria` VALUES (1, -1, 0); -INSERT INTO `browse_criteria` VALUES (2, -2, 1); -INSERT INTO `browse_criteria` VALUES (3, -3, 2); -INSERT INTO `browse_criteria` VALUES (4, -4, 3); -INSERT INTO `browse_criteria` VALUES (5, -5, 4); - --- -- Dumping data for table `dashlet_disables` -- @@ -65,27 +55,22 @@ INSERT INTO `data_types` VALUES (4, 'INT'); INSERT INTO `data_types` VALUES (5, 'FLOAT'); -- --- Dumping data for table `dependant_document_instance` --- - - --- --- Dumping data for table `dependant_document_template` +-- Dumping data for table `discussion_comments` -- -- --- Dumping data for table `discussion_comments` +-- Dumping data for table `discussion_threads` -- -- --- Dumping data for table `discussion_threads` +-- Dumping data for table `document_archiving_link` -- -- --- Dumping data for table `document_archiving_link` +-- Dumping data for table `document_content_version` -- @@ -118,6 +103,11 @@ INSERT INTO `document_link_types` VALUES (-1, 'depended on', 'was depended on by INSERT INTO `document_link_types` VALUES (0, 'Default', 'Default (reverse)', 'Default link type'); -- +-- Dumping data for table `document_metadata_version` +-- + + +-- -- Dumping data for table `document_searchable_text` -- @@ -235,16 +225,6 @@ INSERT INTO `folders` VALUES (2, 'Default Unit', 'Default Unit Root Folder', 1, -- --- Dumping data for table `groups_folders_approval_link` --- - - --- --- Dumping data for table `groups_folders_link` --- - - --- -- Dumping data for table `groups_groups_link` -- @@ -622,6 +602,11 @@ INSERT INTO `permissions` VALUES (2, 'ktcore.permissions.write', 'Core: Write', INSERT INTO `permissions` VALUES (3, 'ktcore.permissions.addFolder', 'Core: Add Folder', 1); -- +-- Dumping data for table `plugins` +-- + + +-- -- Dumping data for table `role_allocations` -- @@ -655,7 +640,7 @@ INSERT INTO `status_lookup` VALUES (4, 'Archived'); -- INSERT INTO `system_settings` VALUES (1, 'lastIndexUpdate', '0'); -INSERT INTO `system_settings` VALUES (2, 'knowledgeTreeVersion', '2.99.5'); +INSERT INTO `system_settings` VALUES (2, 'knowledgeTreeVersion', '2.99.7'); INSERT INTO `system_settings` VALUES (3, 'databaseVersion', '2.99.5'); -- @@ -709,6 +694,33 @@ INSERT INTO `upgrades` VALUES (20, 'upgrade*2.99.1*0*upgrade2.99.1', 'Upgrade fr INSERT INTO `upgrades` VALUES (21, 'sql*2.99.1*0*2.99.1/workflow.sql', 'Database upgrade to version 2.99.1: Workflow', '2005-10-07 14:26:15', 1, 'upgrade*2.99.1*0*upgrade2.99.1'); INSERT INTO `upgrades` VALUES (22, 'sql*2.99.1*0*2.99.1/fieldsets.sql', 'Database upgrade to version 2.99.1: Fieldsets', '2005-10-07 14:26:16', 1, 'upgrade*2.99.1*0*upgrade2.99.1'); INSERT INTO `upgrades` VALUES (23, 'func*2.99.1*1*createFieldSets', 'Create a fieldset for each field without one', '2005-10-07 14:26:16', 1, 'upgrade*2.99.1*0*upgrade2.99.1'); +INSERT INTO `upgrades` VALUES (24, 'sql*2.99.2*0*2.99.2/saved_searches.sql', '', '0000-00-00 00:00:00', 1, NULL); +INSERT INTO `upgrades` VALUES (25, 'sql*2.99.2*0*2.99.2/transactions.sql', '', '0000-00-00 00:00:00', 1, NULL); +INSERT INTO `upgrades` VALUES (26, 'sql*2.99.2*0*2.99.2/field_mandatory.sql', '', '0000-00-00 00:00:00', 1, NULL); +INSERT INTO `upgrades` VALUES (27, 'sql*2.99.2*0*2.99.2/fieldsets_system.sql', '', '0000-00-00 00:00:00', 1, NULL); +INSERT INTO `upgrades` VALUES (28, 'sql*2.99.2*0*2.99.2/permission_by_user_and_roles.sql', '', '0000-00-00 00:00:00', 1, NULL); +INSERT INTO `upgrades` VALUES (29, 'sql*2.99.2*0*2.99.2/disabled_metadata.sql', '', '0000-00-00 00:00:00', 1, NULL); +INSERT INTO `upgrades` VALUES (30, 'sql*2.99.2*0*2.99.2/searchable_text.sql', '', '0000-00-00 00:00:00', 1, NULL); +INSERT INTO `upgrades` VALUES (31, 'sql*2.99.2*0*2.99.2/workflow.sql', '', '0000-00-00 00:00:00', 1, NULL); +INSERT INTO `upgrades` VALUES (32, 'sql*2.99.2*1*2.99.2/1-constraints.sql', '', '0000-00-00 00:00:00', 1, NULL); +INSERT INTO `upgrades` VALUES (33, 'sql*2.99.3*0*2.99.3/notifications.sql', '', '0000-00-00 00:00:00', 1, NULL); +INSERT INTO `upgrades` VALUES (34, 'sql*2.99.3*0*2.99.3/last_modified_user.sql', '', '0000-00-00 00:00:00', 1, NULL); +INSERT INTO `upgrades` VALUES (35, 'sql*2.99.3*0*2.99.3/authentication_sources.sql', '', '0000-00-00 00:00:00', 1, NULL); +INSERT INTO `upgrades` VALUES (36, 'sql*2.99.3*0*2.99.3/document_fields_constraints.sql', '', '0000-00-00 00:00:00', 1, NULL); +INSERT INTO `upgrades` VALUES (37, 'sql*2.99.5*0*2.99.5/dashlet_disabling.sql', '', '0000-00-00 00:00:00', 1, NULL); +INSERT INTO `upgrades` VALUES (38, 'sql*2.99.5*0*2.99.5/role_allocations.sql', '', '0000-00-00 00:00:00', 1, NULL); +INSERT INTO `upgrades` VALUES (39, 'sql*2.99.5*0*2.99.5/transaction_namespaces.sql', '', '0000-00-00 00:00:00', 1, NULL); +INSERT INTO `upgrades` VALUES (40, 'sql*2.99.5*0*2.99.5/fieldset_field_descriptions.sql', '', '0000-00-00 00:00:00', 1, NULL); +INSERT INTO `upgrades` VALUES (41, 'sql*2.99.5*0*2.99.5/role_changes.sql', '', '0000-00-00 00:00:00', 1, NULL); +INSERT INTO `upgrades` VALUES (42, 'sql*2.99.6*0*2.99.6/table_cleanup.sql', 'Database upgrade to version 2.99.6: Table cleanup', '2006-01-20 17:04:05', 1, 'upgrade*2.99.7*99*upgrade2.99.7'); +INSERT INTO `upgrades` VALUES (43, 'sql*2.99.6*0*2.99.6/plugin-registration.sql', 'Database upgrade to version 2.99.6: Plugin-registration', '2006-01-20 17:04:05', 1, 'upgrade*2.99.7*99*upgrade2.99.7'); +INSERT INTO `upgrades` VALUES (44, 'sql*2.99.7*0*2.99.7/documents_normalisation.sql', 'Database upgrade to version 2.99.7: Documents normalisation', '2006-01-20 17:04:05', 1, 'upgrade*2.99.7*99*upgrade2.99.7'); +INSERT INTO `upgrades` VALUES (45, 'sql*2.99.7*0*2.99.7/help_replacement.sql', 'Database upgrade to version 2.99.7: Help replacement', '2006-01-20 17:04:05', 1, 'upgrade*2.99.7*99*upgrade2.99.7'); +INSERT INTO `upgrades` VALUES (46, 'sql*2.99.7*0*2.99.7/table_cleanup.sql', 'Database upgrade to version 2.99.7: Table cleanup', '2006-01-20 17:04:07', 1, 'upgrade*2.99.7*99*upgrade2.99.7'); +INSERT INTO `upgrades` VALUES (47, 'func*2.99.7*1*normaliseDocuments', 'Normalise the documents table', '2006-01-20 17:04:07', 1, 'upgrade*2.99.7*99*upgrade2.99.7'); +INSERT INTO `upgrades` VALUES (48, 'sql*2.99.7*10*2.99.7/10-documents_normalisation.sql', 'Database upgrade to version 2.99.7: Documents normalisation', '2006-01-20 17:04:07', 1, 'upgrade*2.99.7*99*upgrade2.99.7'); +INSERT INTO `upgrades` VALUES (49, 'sql*2.99.7*20*2.99.7/20-fields.sql', 'Database upgrade to version 2.99.7: Fields', '2006-01-20 17:04:07', 1, 'upgrade*2.99.7*99*upgrade2.99.7'); +INSERT INTO `upgrades` VALUES (50, 'upgrade*2.99.7*99*upgrade2.99.7', 'Upgrade from version 2.99.5 to 2.99.7', '2006-01-20 17:04:07', 1, 'upgrade*2.99.7*99*upgrade2.99.7'); -- -- Dumping data for table `users` @@ -727,24 +739,6 @@ INSERT INTO `users_groups_link` VALUES (2, 2, 2); INSERT INTO `users_groups_link` VALUES (3, 3, 3); -- --- Dumping data for table `web_documents` --- - - --- --- Dumping data for table `web_documents_status_lookup` --- - -INSERT INTO `web_documents_status_lookup` VALUES (1, 'Pending'); -INSERT INTO `web_documents_status_lookup` VALUES (2, 'Published'); -INSERT INTO `web_documents_status_lookup` VALUES (3, 'Not Published'); - --- --- Dumping data for table `web_sites` --- - - --- -- Dumping data for table `workflow_actions` -- @@ -807,6 +801,7 @@ INSERT INTO `zseq_archiving_type_lookup` VALUES (2); -- Dumping data for table `zseq_authentication_sources` -- +INSERT INTO `zseq_authentication_sources` VALUES (1); -- -- Dumping data for table `zseq_browse_criteria` @@ -818,6 +813,7 @@ INSERT INTO `zseq_browse_criteria` VALUES (5); -- Dumping data for table `zseq_dashlet_disables` -- +INSERT INTO `zseq_dashlet_disables` VALUES (1); -- -- Dumping data for table `zseq_data_types` @@ -856,6 +852,12 @@ INSERT INTO `zseq_discussion_threads` VALUES (1); INSERT INTO `zseq_document_archiving_link` VALUES (1); -- +-- Dumping data for table `zseq_document_content_version` +-- + +INSERT INTO `zseq_document_content_version` VALUES (1); + +-- -- Dumping data for table `zseq_document_fields` -- @@ -880,6 +882,12 @@ INSERT INTO `zseq_document_link` VALUES (1); INSERT INTO `zseq_document_link_types` VALUES (2); -- +-- Dumping data for table `zseq_document_metadata_version` +-- + +INSERT INTO `zseq_document_metadata_version` VALUES (1); + +-- -- Dumping data for table `zseq_document_subscriptions` -- @@ -907,6 +915,7 @@ INSERT INTO `zseq_document_type_fields_link` VALUES (1); -- Dumping data for table `zseq_document_type_fieldsets_link` -- +INSERT INTO `zseq_document_type_fieldsets_link` VALUES (1); -- -- Dumping data for table `zseq_document_types_lookup` @@ -924,11 +933,13 @@ INSERT INTO `zseq_documents` VALUES (1); -- Dumping data for table `zseq_field_behaviours` -- +INSERT INTO `zseq_field_behaviours` VALUES (1); -- -- Dumping data for table `zseq_field_value_instances` -- +INSERT INTO `zseq_field_value_instances` VALUES (1); -- -- Dumping data for table `zseq_fieldsets` @@ -961,21 +972,10 @@ INSERT INTO `zseq_folders` VALUES (2); INSERT INTO `zseq_folders_users_roles_link` VALUES (1); -- --- Dumping data for table `zseq_groups_folders_approval_link` --- - -INSERT INTO `zseq_groups_folders_approval_link` VALUES (1); - --- --- Dumping data for table `zseq_groups_folders_link` --- - -INSERT INTO `zseq_groups_folders_link` VALUES (1); - --- -- Dumping data for table `zseq_groups_groups_link` -- +INSERT INTO `zseq_groups_groups_link` VALUES (1); -- -- Dumping data for table `zseq_groups_lookup` @@ -999,6 +999,7 @@ INSERT INTO `zseq_help` VALUES (98); -- Dumping data for table `zseq_help_replacement` -- +INSERT INTO `zseq_help_replacement` VALUES (1); -- -- Dumping data for table `zseq_links` @@ -1016,6 +1017,7 @@ INSERT INTO `zseq_metadata_lookup` VALUES (1); -- Dumping data for table `zseq_metadata_lookup_tree` -- +INSERT INTO `zseq_metadata_lookup_tree` VALUES (1); -- -- Dumping data for table `zseq_mime_types` @@ -1033,6 +1035,7 @@ INSERT INTO `zseq_news` VALUES (1); -- Dumping data for table `zseq_notifications` -- +INSERT INTO `zseq_notifications` VALUES (1); -- -- Dumping data for table `zseq_organisations_lookup` @@ -1056,6 +1059,7 @@ INSERT INTO `zseq_permission_descriptors` VALUES (2); -- Dumping data for table `zseq_permission_dynamic_conditions` -- +INSERT INTO `zseq_permission_dynamic_conditions` VALUES (1); -- -- Dumping data for table `zseq_permission_lookup_assignments` @@ -1082,26 +1086,28 @@ INSERT INTO `zseq_permission_objects` VALUES (1); INSERT INTO `zseq_permissions` VALUES (3); -- --- Dumping data for table `zseq_role_allocations` +-- Dumping data for table `zseq_plugins` -- +INSERT INTO `zseq_plugins` VALUES (1); -- --- Dumping data for table `zseq_roles` +-- Dumping data for table `zseq_role_allocations` -- -INSERT INTO `zseq_roles` VALUES (1); +INSERT INTO `zseq_role_allocations` VALUES (1); -- --- Dumping data for table `zseq_saved_searches` +-- Dumping data for table `zseq_roles` -- +INSERT INTO `zseq_roles` VALUES (1); -- --- Dumping data for table `zseq_search_document_user_link` +-- Dumping data for table `zseq_saved_searches` -- -INSERT INTO `zseq_search_document_user_link` VALUES (1); +INSERT INTO `zseq_saved_searches` VALUES (1); -- -- Dumping data for table `zseq_status_lookup` @@ -1143,7 +1149,7 @@ INSERT INTO `zseq_units_organisations_link` VALUES (1); -- Dumping data for table `zseq_upgrades` -- -INSERT INTO `zseq_upgrades` VALUES (23); +INSERT INTO `zseq_upgrades` VALUES (50); -- -- Dumping data for table `zseq_users` @@ -1158,36 +1164,21 @@ INSERT INTO `zseq_users` VALUES (3); INSERT INTO `zseq_users_groups_link` VALUES (3); -- --- Dumping data for table `zseq_web_documents` --- - -INSERT INTO `zseq_web_documents` VALUES (1); - --- --- Dumping data for table `zseq_web_documents_status_lookup` --- - -INSERT INTO `zseq_web_documents_status_lookup` VALUES (3); - --- --- Dumping data for table `zseq_web_sites` --- - -INSERT INTO `zseq_web_sites` VALUES (1); - --- -- Dumping data for table `zseq_workflow_states` -- +INSERT INTO `zseq_workflow_states` VALUES (1); -- -- Dumping data for table `zseq_workflow_transitions` -- +INSERT INTO `zseq_workflow_transitions` VALUES (1); -- -- Dumping data for table `zseq_workflows` -- +INSERT INTO `zseq_workflows` VALUES (1); SET FOREIGN_KEY_CHECKS=1; diff --git a/sql/mysql/install/structure.sql b/sql/mysql/install/structure.sql index a3bf9b1..b559408 100644 --- a/sql/mysql/install/structure.sql +++ b/sql/mysql/install/structure.sql @@ -1,9 +1,9 @@ -- phpMyAdmin SQL Dump --- version 2.6.4-pl4-Debian-1 +-- version 2.7.0-pl2-Debian-1 -- http://www.phpmyadmin.net -- -- Host: localhost --- Generation Time: Dec 15, 2005 at 06:18 PM +-- Generation Time: Jan 20, 2006 at 05:05 PM -- Server version: 4.1.15 -- PHP Version: 4.4.0-3 @@ -26,7 +26,7 @@ CREATE TABLE `active_sessions` ( `ip` char(30) default NULL, UNIQUE KEY `id` (`id`), KEY `session_id_idx` (`session_id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -41,7 +41,7 @@ CREATE TABLE `archive_restoration_request` ( `admin_user_id` int(11) NOT NULL default '0', `datetime` datetime NOT NULL default '0000-00-00 00:00:00', UNIQUE KEY `id` (`id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -56,7 +56,7 @@ CREATE TABLE `archiving_settings` ( `document_transaction_id` int(11) default NULL, `time_period_id` int(11) default NULL, UNIQUE KEY `id` (`id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -68,7 +68,7 @@ CREATE TABLE `archiving_type_lookup` ( `id` int(11) NOT NULL default '0', `name` char(100) default NULL, UNIQUE KEY `id` (`id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -86,22 +86,7 @@ CREATE TABLE `authentication_sources` ( `is_group_source` tinyint(1) NOT NULL default '0', PRIMARY KEY (`id`), KEY `namespace` (`namespace`) -) TYPE=InnoDB ; - --- -------------------------------------------------------- - --- --- Table structure for table `browse_criteria` --- - -CREATE TABLE `browse_criteria` ( - `id` int(11) NOT NULL default '0', - `criteria_id` int(11) NOT NULL default '0', - `precedence` int(11) NOT NULL default '0', - PRIMARY KEY (`id`), - UNIQUE KEY `criteria_id` (`criteria_id`), - UNIQUE KEY `precedence` (`precedence`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -116,7 +101,7 @@ CREATE TABLE `dashlet_disables` ( UNIQUE KEY `id` (`id`), KEY `user_id` (`user_id`), KEY `dashlet_namespace` (`dashlet_namespace`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -128,37 +113,7 @@ CREATE TABLE `data_types` ( `id` int(11) NOT NULL default '0', `name` char(255) NOT NULL default '', UNIQUE KEY `id` (`id`) -) TYPE=InnoDB ; - --- -------------------------------------------------------- - --- --- Table structure for table `dependant_document_instance` --- - -CREATE TABLE `dependant_document_instance` ( - `id` int(11) NOT NULL default '0', - `document_title` text NOT NULL, - `user_id` int(11) NOT NULL default '0', - `template_document_id` int(11) default NULL, - `parent_document_id` int(11) default NULL, - UNIQUE KEY `id` (`id`) -) TYPE=InnoDB ; - --- -------------------------------------------------------- - --- --- Table structure for table `dependant_document_template` --- - -CREATE TABLE `dependant_document_template` ( - `id` int(11) NOT NULL default '0', - `document_title` text NOT NULL, - `default_user_id` int(11) NOT NULL default '0', - `template_document_id` int(11) default NULL, - `group_folder_approval_link_id` int(11) default NULL, - UNIQUE KEY `id` (`id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -175,7 +130,7 @@ CREATE TABLE `discussion_comments` ( `body` text, `date` datetime default NULL, UNIQUE KEY `id` (`id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -195,7 +150,7 @@ CREATE TABLE `discussion_threads` ( `close_reason` text NOT NULL default '', `creator_id` int(11) NOT NULL default '0', UNIQUE KEY `id` (`id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -208,7 +163,27 @@ CREATE TABLE `document_archiving_link` ( `document_id` int(11) NOT NULL default '0', `archiving_settings_id` int(11) NOT NULL default '0', UNIQUE KEY `id` (`id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `document_content_version` +-- + +CREATE TABLE `document_content_version` ( + `id` int(11) NOT NULL default '0', + `document_id` int(11) NOT NULL default '0', + `filename` text NOT NULL, + `size` bigint(20) NOT NULL default '0', + `mime_id` int(11) NOT NULL default '0', + `major_version` int(11) NOT NULL default '0', + `minor_version` int(11) NOT NULL default '0', + `storage_path` varchar(250) default NULL, + UNIQUE KEY `id` (`id`), + KEY `storage_path` (`storage_path`), + KEY `document_id` (`document_id`) +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -228,7 +203,7 @@ CREATE TABLE `document_fields` ( `description` text NOT NULL, UNIQUE KEY `id` (`id`), KEY `parent_fieldset` (`parent_fieldset`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -238,13 +213,13 @@ CREATE TABLE `document_fields` ( CREATE TABLE `document_fields_link` ( `id` int(11) NOT NULL default '0', - `document_id` int(11) NOT NULL default '0', `document_field_id` int(11) NOT NULL default '0', `value` char(255) NOT NULL default '', + `metadata_version_id` int(11) default NULL, UNIQUE KEY `id` (`id`), - KEY `document_id` (`document_id`), - KEY `document_field_id` (`document_field_id`) -) TYPE=InnoDB ; + KEY `document_field_id` (`document_field_id`), + KEY `metadata_version_id` (`metadata_version_id`) +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -257,7 +232,7 @@ CREATE TABLE `document_incomplete` ( `contents` tinyint(1) unsigned NOT NULL default '0', `metadata` tinyint(1) unsigned NOT NULL default '0', PRIMARY KEY (`id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -271,7 +246,7 @@ CREATE TABLE `document_link` ( `child_document_id` int(11) NOT NULL default '0', `link_type_id` int(11) NOT NULL default '0', UNIQUE KEY `id` (`id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -285,7 +260,33 @@ CREATE TABLE `document_link_types` ( `reverse_name` char(100) NOT NULL default '', `description` char(255) NOT NULL default '', UNIQUE KEY `id` (`id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `document_metadata_version` +-- + +CREATE TABLE `document_metadata_version` ( + `id` int(11) NOT NULL default '0', + `document_id` int(11) NOT NULL default '0', + `content_version_id` int(11) NOT NULL default '0', + `document_type_id` int(11) NOT NULL default '0', + `name` text NOT NULL, + `description` varchar(200) NOT NULL default '', + `status_id` int(11) default NULL, + `metadata_version` int(11) NOT NULL default '0', + `version_created` datetime NOT NULL default '0000-00-00 00:00:00', + `version_creator_id` int(11) NOT NULL default '0', + UNIQUE KEY `id` (`id`), + KEY `fk_document_type_id` (`document_type_id`), + KEY `fk_status_id` (`status_id`), + KEY `document_id` (`document_id`), + KEY `version_created` (`version_created`), + KEY `version_creator_id` (`version_creator_id`), + KEY `content_version_id` (`content_version_id`) +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -298,7 +299,7 @@ CREATE TABLE `document_searchable_text` ( `document_text` mediumtext, KEY `document_text_document_id_indx` (`document_id`), FULLTEXT KEY `document_text` (`document_text`) -) TYPE=MyISAM ; +) TYPE=MyISAM; -- -------------------------------------------------------- @@ -312,7 +313,7 @@ CREATE TABLE `document_subscriptions` ( `document_id` int(11) NOT NULL default '0', `is_alerted` tinyint(1) default NULL, UNIQUE KEY `id` (`id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -325,7 +326,7 @@ CREATE TABLE `document_text` ( `document_text` mediumtext, KEY `document_text_document_id_indx` (`document_id`), FULLTEXT KEY `document_text` (`document_text`) -) TYPE=MyISAM ; +) TYPE=MyISAM; -- -------------------------------------------------------- @@ -338,7 +339,7 @@ CREATE TABLE `document_transaction_text` ( `document_text` mediumtext, KEY `document_text_document_id_indx` (`document_id`), FULLTEXT KEY `document_text` (`document_text`) -) TYPE=MyISAM ; +) TYPE=MyISAM; -- -------------------------------------------------------- @@ -352,7 +353,7 @@ CREATE TABLE `document_transaction_types_lookup` ( `namespace` varchar(250) NOT NULL default '', UNIQUE KEY `id` (`id`), KEY `namespace` (`namespace`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -373,7 +374,7 @@ CREATE TABLE `document_transactions` ( UNIQUE KEY `id` (`id`), KEY `fk_document_id` (`document_id`), KEY `fk_user_id` (`user_id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -387,7 +388,7 @@ CREATE TABLE `document_type_fields_link` ( `field_id` int(11) NOT NULL default '0', `is_mandatory` tinyint(1) NOT NULL default '0', UNIQUE KEY `id` (`id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -402,7 +403,7 @@ CREATE TABLE `document_type_fieldsets_link` ( UNIQUE KEY `id` (`id`), KEY `document_type_id` (`document_type_id`), KEY `fieldset_id` (`fieldset_id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -415,7 +416,7 @@ CREATE TABLE `document_types_lookup` ( `name` char(100) default NULL, UNIQUE KEY `id` (`id`), UNIQUE KEY `name` (`name`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -425,18 +426,9 @@ CREATE TABLE `document_types_lookup` ( CREATE TABLE `documents` ( `id` int(11) NOT NULL default '0', - `document_type_id` int(11) NOT NULL default '0', - `name` text NOT NULL, - `filename` text NOT NULL, - `size` bigint(20) NOT NULL default '0', `creator_id` int(11) NOT NULL default '0', `modified` datetime NOT NULL default '0000-00-00 00:00:00', - `description` varchar(200) NOT NULL default '', - `security` int(11) NOT NULL default '0', - `mime_id` int(11) NOT NULL default '0', - `folder_id` int(11) default '1', - `major_version` int(11) NOT NULL default '0', - `minor_version` int(11) NOT NULL default '0', + `folder_id` int(11) NOT NULL default '0', `is_checked_out` tinyint(1) NOT NULL default '0', `parent_folder_ids` text, `full_path` text, @@ -445,12 +437,10 @@ CREATE TABLE `documents` ( `created` datetime NOT NULL default '0000-00-00 00:00:00', `permission_object_id` int(11) default NULL, `permission_lookup_id` int(11) default NULL, - `live_document_id` int(11) default NULL, `metadata_version` int(11) NOT NULL default '0', - `storage_path` varchar(250) default NULL, `modified_user_id` int(11) NOT NULL default '0', + `metadata_version_id` int(11) default NULL, UNIQUE KEY `id` (`id`), - KEY `fk_document_type_id` (`document_type_id`), KEY `fk_creator_id` (`creator_id`), KEY `fk_folder_id` (`folder_id`), KEY `fk_checked_out_user_id` (`checked_out_user_id`), @@ -458,10 +448,9 @@ CREATE TABLE `documents` ( KEY `created` (`created`), KEY `permission_object_id` (`permission_object_id`), KEY `permission_lookup_id` (`permission_lookup_id`), - KEY `live_document_id` (`live_document_id`), - KEY `storage_path` (`storage_path`), - KEY `modified_user_id` (`modified_user_id`) -) TYPE=InnoDB ; + KEY `modified_user_id` (`modified_user_id`), + KEY `metadata_version_id` (`metadata_version_id`) +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -476,7 +465,7 @@ CREATE TABLE `field_behaviour_options` ( KEY `behaviour_id` (`behaviour_id`), KEY `field_id` (`field_id`), KEY `instance_id` (`instance_id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -492,7 +481,7 @@ CREATE TABLE `field_behaviours` ( PRIMARY KEY (`id`), KEY `field_id` (`field_id`), KEY `name` (`name`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -507,7 +496,7 @@ CREATE TABLE `field_orders` ( UNIQUE KEY `child_field` (`child_field_id`), KEY `parent_field` (`parent_field_id`), KEY `fieldset_id` (`fieldset_id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -524,7 +513,7 @@ CREATE TABLE `field_value_instances` ( KEY `field_id` (`field_id`), KEY `field_value_id` (`field_value_id`), KEY `behaviour_id` (`behaviour_id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -549,7 +538,7 @@ CREATE TABLE `fieldsets` ( KEY `is_complete` (`is_complete`), KEY `is_system` (`is_system`), KEY `master_field` (`master_field`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -564,7 +553,7 @@ CREATE TABLE `folder_doctypes_link` ( UNIQUE KEY `id` (`id`), KEY `fk_folder_id` (`folder_id`), KEY `fk_document_type_id` (`document_type_id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -578,7 +567,7 @@ CREATE TABLE `folder_subscriptions` ( `folder_id` int(11) NOT NULL default '0', `is_alerted` tinyint(1) default NULL, UNIQUE KEY `id` (`id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -605,7 +594,7 @@ CREATE TABLE `folders` ( KEY `fk_unit_id` (`unit_id`), KEY `permission_object_id` (`permission_object_id`), KEY `permission_lookup_id` (`permission_lookup_id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -623,40 +612,7 @@ CREATE TABLE `folders_users_roles_link` ( `active` tinyint(1) default NULL, `dependant_documents_created` tinyint(1) default NULL, UNIQUE KEY `id` (`id`) -) TYPE=InnoDB ; - --- -------------------------------------------------------- - --- --- Table structure for table `groups_folders_approval_link` --- - -CREATE TABLE `groups_folders_approval_link` ( - `id` int(11) NOT NULL default '0', - `folder_id` int(11) NOT NULL default '0', - `group_id` int(11) NOT NULL default '0', - `precedence` int(11) NOT NULL default '0', - `role_id` int(11) NOT NULL default '0', - `user_id` int(11) NOT NULL default '0', - UNIQUE KEY `id` (`id`) -) TYPE=InnoDB ; - --- -------------------------------------------------------- - --- --- Table structure for table `groups_folders_link` --- - -CREATE TABLE `groups_folders_link` ( - `id` int(11) NOT NULL default '0', - `group_id` int(11) NOT NULL default '0', - `folder_id` int(11) NOT NULL default '0', - `can_read` tinyint(1) NOT NULL default '0', - `can_write` tinyint(1) NOT NULL default '0', - UNIQUE KEY `id` (`id`), - KEY `fk_group_id` (`group_id`), - KEY `fk_folder_id` (`folder_id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -669,7 +625,7 @@ CREATE TABLE `groups_groups_link` ( `parent_group_id` int(11) NOT NULL default '0', `member_group_id` int(11) NOT NULL default '0', PRIMARY KEY (`id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -684,7 +640,7 @@ CREATE TABLE `groups_lookup` ( `is_unit_admin` tinyint(1) NOT NULL default '0', UNIQUE KEY `id` (`id`), UNIQUE KEY `name` (`name`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -699,7 +655,7 @@ CREATE TABLE `groups_units_link` ( UNIQUE KEY `id` (`id`), KEY `fk_group_id` (`group_id`), KEY `fk_unit_id` (`unit_id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -712,7 +668,7 @@ CREATE TABLE `help` ( `fSection` varchar(100) NOT NULL default '', `help_info` text NOT NULL, UNIQUE KEY `id` (`id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -722,11 +678,10 @@ CREATE TABLE `help` ( CREATE TABLE `help_replacement` ( `id` int(11) NOT NULL default '0', - `name` varchar(255) NOT NULL default '', - `title` varchar(255) NOT NULL default '', + `name` varchar(100) NOT NULL default '', `description` text NOT NULL, PRIMARY KEY (`id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -740,7 +695,7 @@ CREATE TABLE `links` ( `url` char(100) NOT NULL default '', `rank` int(11) NOT NULL default '0', UNIQUE KEY `id` (`id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -758,7 +713,7 @@ CREATE TABLE `metadata_lookup` ( UNIQUE KEY `id` (`id`), KEY `disabled` (`disabled`), KEY `is_stuck` (`is_stuck`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -774,7 +729,7 @@ CREATE TABLE `metadata_lookup_tree` ( UNIQUE KEY `id` (`id`), KEY `metadata_lookup_tree_parent` (`metadata_lookup_tree_parent`), KEY `document_field_id` (`document_field_id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -788,7 +743,7 @@ CREATE TABLE `mime_types` ( `mimetypes` char(100) NOT NULL default '', `icon_path` char(255) default NULL, UNIQUE KEY `id` (`id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -806,7 +761,7 @@ CREATE TABLE `news` ( `image_mime_type_id` int(11) default NULL, `active` tinyint(1) default NULL, UNIQUE KEY `id` (`id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -827,7 +782,7 @@ CREATE TABLE `notifications` ( UNIQUE KEY `id` (`id`), KEY `type` (`type`), KEY `user_id` (`user_id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -840,22 +795,10 @@ CREATE TABLE `organisations_lookup` ( `name` char(100) NOT NULL default '', UNIQUE KEY `id` (`id`), UNIQUE KEY `name` (`name`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- -CREATE TABLE `plugins` ( - `id` int(11) NOT NULL default '0', - `namespace` varchar(255) NOT NULL default '', - `path` varchar(255) NOT NULL default '', - `version` int(11) NOT NULL default '0', - `disabled` tinyint(1) NOT NULL default '0', - `data` text, - PRIMARY KEY (`id`), - KEY `name` (`namespace`) -) ENGINE=InnoDB; - - -- -- Table structure for table `permission_assignments` -- @@ -870,7 +813,7 @@ CREATE TABLE `permission_assignments` ( KEY `permission_id` (`permission_id`), KEY `permission_object_id` (`permission_object_id`), KEY `permission_descriptor_id` (`permission_descriptor_id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -884,7 +827,7 @@ CREATE TABLE `permission_descriptor_groups` ( UNIQUE KEY `descriptor_id` (`descriptor_id`,`group_id`), KEY `descriptor_id_2` (`descriptor_id`), KEY `group_id` (`group_id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -898,7 +841,7 @@ CREATE TABLE `permission_descriptor_roles` ( UNIQUE KEY `descriptor_id` (`descriptor_id`,`role_id`), KEY `descriptor_id_2` (`descriptor_id`), KEY `role_id` (`role_id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -912,7 +855,7 @@ CREATE TABLE `permission_descriptor_users` ( UNIQUE KEY `descriptor_id` (`descriptor_id`,`user_id`), KEY `descriptor_id_2` (`descriptor_id`), KEY `user_id` (`user_id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -927,7 +870,7 @@ CREATE TABLE `permission_descriptors` ( PRIMARY KEY (`id`), UNIQUE KEY `descriptor_2` (`descriptor`), KEY `descriptor` (`descriptor`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -940,7 +883,7 @@ CREATE TABLE `permission_dynamic_assignments` ( `permission_id` int(11) NOT NULL default '0', KEY `dynamic_conditiond_id` (`dynamic_condition_id`), KEY `permission_id` (`permission_id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -957,7 +900,7 @@ CREATE TABLE `permission_dynamic_conditions` ( KEY `permission_object_id` (`permission_object_id`), KEY `group_id` (`group_id`), KEY `condition_id` (`condition_id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -975,7 +918,7 @@ CREATE TABLE `permission_lookup_assignments` ( KEY `permission_id` (`permission_id`), KEY `permission_lookup_id` (`permission_lookup_id`), KEY `permission_descriptor_id` (`permission_descriptor_id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -986,7 +929,7 @@ CREATE TABLE `permission_lookup_assignments` ( CREATE TABLE `permission_lookups` ( `id` int(11) NOT NULL default '0', PRIMARY KEY (`id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -997,7 +940,7 @@ CREATE TABLE `permission_lookups` ( CREATE TABLE `permission_objects` ( `id` int(11) NOT NULL default '0', PRIMARY KEY (`id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -1012,7 +955,24 @@ CREATE TABLE `permissions` ( `built_in` tinyint(4) NOT NULL default '0', PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) -) TYPE=InnoDB ; +) TYPE=InnoDB; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `plugins` +-- + +CREATE TABLE `plugins` ( + `id` int(11) NOT NULL default '0', + `namespace` varchar(255) NOT NULL default '', + `path` varchar(255) NOT NULL default '', + `version` int(11) NOT NULL default '0', + `disabled` tinyint(1) NOT NULL default '0', + `data` text, + PRIMARY KEY (`id`), + KEY `name` (`namespace`) +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -1027,7 +987,7 @@ CREATE TABLE `role_allocations` ( `permission_descriptor_id` int(11) NOT NULL default '0', UNIQUE KEY `id` (`id`), KEY `folder_id` (`folder_id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -1040,7 +1000,7 @@ CREATE TABLE `roles` ( `name` char(255) NOT NULL default '', UNIQUE KEY `id` (`id`), UNIQUE KEY `name` (`name`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -1061,7 +1021,7 @@ CREATE TABLE `saved_searches` ( KEY `is_condition` (`is_condition`), KEY `is_complete` (`is_complete`), KEY `user_id` (`user_id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -1074,7 +1034,7 @@ CREATE TABLE `search_document_user_link` ( `user_id` int(11) default NULL, KEY `fk_user_id` (`user_id`), KEY `fk_document_ids` (`document_id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -1086,7 +1046,7 @@ CREATE TABLE `status_lookup` ( `id` int(11) NOT NULL default '0', `name` char(255) default NULL, UNIQUE KEY `id` (`id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -1099,7 +1059,7 @@ CREATE TABLE `system_settings` ( `name` char(255) NOT NULL default '', `value` char(255) NOT NULL default '', UNIQUE KEY `id` (`id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -1112,7 +1072,7 @@ CREATE TABLE `time_period` ( `time_unit_id` int(11) default NULL, `units` int(11) default NULL, UNIQUE KEY `id` (`id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -1124,7 +1084,7 @@ CREATE TABLE `time_unit_lookup` ( `id` int(11) NOT NULL default '0', `name` char(100) default NULL, UNIQUE KEY `id` (`id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -1137,7 +1097,7 @@ CREATE TABLE `units_lookup` ( `name` char(100) NOT NULL default '', UNIQUE KEY `id` (`id`), UNIQUE KEY `name` (`name`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -1152,7 +1112,7 @@ CREATE TABLE `units_organisations_link` ( UNIQUE KEY `id` (`id`), KEY `fk_unit_id` (`unit_id`), KEY `fk_organisation_id` (`organisation_id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -1170,7 +1130,7 @@ CREATE TABLE `upgrades` ( PRIMARY KEY (`id`), KEY `descriptor` (`descriptor`), KEY `parent` (`parent`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -1197,7 +1157,7 @@ CREATE TABLE `users` ( UNIQUE KEY `id` (`id`), UNIQUE KEY `username` (`username`), KEY `authentication_source` (`authentication_source_id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -1212,49 +1172,7 @@ CREATE TABLE `users_groups_link` ( UNIQUE KEY `id` (`id`), KEY `fk_user_id` (`user_id`), KEY `fk_group_id` (`group_id`) -) TYPE=InnoDB ; - --- -------------------------------------------------------- - --- --- Table structure for table `web_documents` --- - -CREATE TABLE `web_documents` ( - `id` int(11) NOT NULL default '0', - `document_id` int(11) NOT NULL default '0', - `web_site_id` int(11) NOT NULL default '0', - `unit_id` int(11) NOT NULL default '0', - `status_id` int(11) NOT NULL default '0', - `datetime` datetime NOT NULL default '0000-00-00 00:00:00', - UNIQUE KEY `id` (`id`) -) TYPE=InnoDB ; - --- -------------------------------------------------------- - --- --- Table structure for table `web_documents_status_lookup` --- - -CREATE TABLE `web_documents_status_lookup` ( - `id` int(11) NOT NULL default '0', - `name` char(50) NOT NULL default '', - UNIQUE KEY `id` (`id`) -) TYPE=InnoDB ; - --- -------------------------------------------------------- - --- --- Table structure for table `web_sites` --- - -CREATE TABLE `web_sites` ( - `id` int(11) NOT NULL default '0', - `web_site_name` char(100) NOT NULL default '', - `web_site_url` char(50) NOT NULL default '', - `web_master_id` int(11) NOT NULL default '0', - UNIQUE KEY `id` (`id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -1267,7 +1185,7 @@ CREATE TABLE `workflow_actions` ( `action_name` char(255) NOT NULL default '', KEY `workflow_id` (`workflow_id`), KEY `action_name` (`action_name`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -1282,7 +1200,7 @@ CREATE TABLE `workflow_documents` ( PRIMARY KEY (`document_id`), KEY `workflow_id` (`workflow_id`), KEY `state_id` (`state_id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -1295,7 +1213,7 @@ CREATE TABLE `workflow_state_actions` ( `action_name` char(255) NOT NULL default '0', KEY `state_id` (`state_id`), KEY `action_name` (`action_name`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -1306,7 +1224,7 @@ CREATE TABLE `workflow_state_actions` ( CREATE TABLE `workflow_state_transitions` ( `state_id` int(11) NOT NULL default '0', `transition_id` int(11) NOT NULL default '0' -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -1324,7 +1242,7 @@ CREATE TABLE `workflow_states` ( KEY `workflow_id` (`workflow_id`), KEY `name` (`name`), KEY `inform_descriptor_id` (`inform_descriptor_id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -1351,7 +1269,7 @@ CREATE TABLE `workflow_transitions` ( KEY `guard_condition` (`guard_condition_id`), KEY `guard_group_id` (`guard_group_id`), KEY `guard_role_id` (`guard_role_id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -1367,7 +1285,7 @@ CREATE TABLE `workflows` ( PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`), KEY `start_state_id` (`start_state_id`) -) TYPE=InnoDB ; +) TYPE=InnoDB; -- -------------------------------------------------------- @@ -1376,9 +1294,9 @@ CREATE TABLE `workflows` ( -- CREATE TABLE `zseq_active_sessions` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=2 ; -- -------------------------------------------------------- @@ -1387,9 +1305,9 @@ CREATE TABLE `zseq_active_sessions` ( -- CREATE TABLE `zseq_archive_restoration_request` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=2 ; -- -------------------------------------------------------- @@ -1398,9 +1316,9 @@ CREATE TABLE `zseq_archive_restoration_request` ( -- CREATE TABLE `zseq_archiving_settings` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=2 ; -- -------------------------------------------------------- @@ -1409,9 +1327,9 @@ CREATE TABLE `zseq_archiving_settings` ( -- CREATE TABLE `zseq_archiving_type_lookup` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=3 ; -- -------------------------------------------------------- @@ -1420,9 +1338,9 @@ CREATE TABLE `zseq_archiving_type_lookup` ( -- CREATE TABLE `zseq_authentication_sources` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=1 ; -- -------------------------------------------------------- @@ -1431,9 +1349,9 @@ CREATE TABLE `zseq_authentication_sources` ( -- CREATE TABLE `zseq_browse_criteria` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=6 ; -- -------------------------------------------------------- @@ -1442,9 +1360,9 @@ CREATE TABLE `zseq_browse_criteria` ( -- CREATE TABLE `zseq_dashlet_disables` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=1 ; -- -------------------------------------------------------- @@ -1453,9 +1371,9 @@ CREATE TABLE `zseq_dashlet_disables` ( -- CREATE TABLE `zseq_data_types` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=6 ; -- -------------------------------------------------------- @@ -1464,9 +1382,9 @@ CREATE TABLE `zseq_data_types` ( -- CREATE TABLE `zseq_dependant_document_instance` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=2 ; -- -------------------------------------------------------- @@ -1475,9 +1393,9 @@ CREATE TABLE `zseq_dependant_document_instance` ( -- CREATE TABLE `zseq_dependant_document_template` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=2 ; -- -------------------------------------------------------- @@ -1486,9 +1404,9 @@ CREATE TABLE `zseq_dependant_document_template` ( -- CREATE TABLE `zseq_discussion_comments` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=2 ; -- -------------------------------------------------------- @@ -1497,9 +1415,9 @@ CREATE TABLE `zseq_discussion_comments` ( -- CREATE TABLE `zseq_discussion_threads` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=2 ; -- -------------------------------------------------------- @@ -1508,9 +1426,20 @@ CREATE TABLE `zseq_discussion_threads` ( -- CREATE TABLE `zseq_document_archiving_link` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, + PRIMARY KEY (`id`) +) TYPE=MyISAM AUTO_INCREMENT=2 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `zseq_document_content_version` +-- + +CREATE TABLE `zseq_document_content_version` ( + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=1 ; -- -------------------------------------------------------- @@ -1519,9 +1448,9 @@ CREATE TABLE `zseq_document_archiving_link` ( -- CREATE TABLE `zseq_document_fields` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=2 ; -- -------------------------------------------------------- @@ -1530,9 +1459,9 @@ CREATE TABLE `zseq_document_fields` ( -- CREATE TABLE `zseq_document_fields_link` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=2 ; -- -------------------------------------------------------- @@ -1541,9 +1470,9 @@ CREATE TABLE `zseq_document_fields_link` ( -- CREATE TABLE `zseq_document_link` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=2 ; -- -------------------------------------------------------- @@ -1552,9 +1481,20 @@ CREATE TABLE `zseq_document_link` ( -- CREATE TABLE `zseq_document_link_types` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, + PRIMARY KEY (`id`) +) TYPE=MyISAM AUTO_INCREMENT=3 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `zseq_document_metadata_version` +-- + +CREATE TABLE `zseq_document_metadata_version` ( + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=1 ; -- -------------------------------------------------------- @@ -1563,9 +1503,9 @@ CREATE TABLE `zseq_document_link_types` ( -- CREATE TABLE `zseq_document_subscriptions` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=2 ; -- -------------------------------------------------------- @@ -1574,9 +1514,9 @@ CREATE TABLE `zseq_document_subscriptions` ( -- CREATE TABLE `zseq_document_transaction_types_lookup` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=17 ; -- -------------------------------------------------------- @@ -1585,9 +1525,9 @@ CREATE TABLE `zseq_document_transaction_types_lookup` ( -- CREATE TABLE `zseq_document_transactions` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=2 ; -- -------------------------------------------------------- @@ -1596,9 +1536,9 @@ CREATE TABLE `zseq_document_transactions` ( -- CREATE TABLE `zseq_document_type_fields_link` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=2 ; -- -------------------------------------------------------- @@ -1607,9 +1547,9 @@ CREATE TABLE `zseq_document_type_fields_link` ( -- CREATE TABLE `zseq_document_type_fieldsets_link` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=1 ; -- -------------------------------------------------------- @@ -1618,9 +1558,9 @@ CREATE TABLE `zseq_document_type_fieldsets_link` ( -- CREATE TABLE `zseq_document_types_lookup` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=2 ; -- -------------------------------------------------------- @@ -1629,9 +1569,9 @@ CREATE TABLE `zseq_document_types_lookup` ( -- CREATE TABLE `zseq_documents` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=2 ; -- -------------------------------------------------------- @@ -1640,9 +1580,9 @@ CREATE TABLE `zseq_documents` ( -- CREATE TABLE `zseq_field_behaviours` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=1 ; -- -------------------------------------------------------- @@ -1651,9 +1591,9 @@ CREATE TABLE `zseq_field_behaviours` ( -- CREATE TABLE `zseq_field_value_instances` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=1 ; -- -------------------------------------------------------- @@ -1662,9 +1602,9 @@ CREATE TABLE `zseq_field_value_instances` ( -- CREATE TABLE `zseq_fieldsets` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=2 ; -- -------------------------------------------------------- @@ -1673,9 +1613,9 @@ CREATE TABLE `zseq_fieldsets` ( -- CREATE TABLE `zseq_folder_doctypes_link` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=3 ; -- -------------------------------------------------------- @@ -1684,9 +1624,9 @@ CREATE TABLE `zseq_folder_doctypes_link` ( -- CREATE TABLE `zseq_folder_subscriptions` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=2 ; -- -------------------------------------------------------- @@ -1695,9 +1635,9 @@ CREATE TABLE `zseq_folder_subscriptions` ( -- CREATE TABLE `zseq_folders` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=3 ; -- -------------------------------------------------------- @@ -1706,31 +1646,9 @@ CREATE TABLE `zseq_folders` ( -- CREATE TABLE `zseq_folders_users_roles_link` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; - --- -------------------------------------------------------- - --- --- Table structure for table `zseq_groups_folders_approval_link` --- - -CREATE TABLE `zseq_groups_folders_approval_link` ( - `id` int(10) unsigned NOT NULL auto_increment, - PRIMARY KEY (`id`) -) TYPE=MyISAM ; - --- -------------------------------------------------------- - --- --- Table structure for table `zseq_groups_folders_link` --- - -CREATE TABLE `zseq_groups_folders_link` ( - `id` int(10) unsigned NOT NULL auto_increment, - PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=2 ; -- -------------------------------------------------------- @@ -1739,9 +1657,9 @@ CREATE TABLE `zseq_groups_folders_link` ( -- CREATE TABLE `zseq_groups_groups_link` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=1 ; -- -------------------------------------------------------- @@ -1750,9 +1668,9 @@ CREATE TABLE `zseq_groups_groups_link` ( -- CREATE TABLE `zseq_groups_lookup` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=4 ; -- -------------------------------------------------------- @@ -1761,9 +1679,9 @@ CREATE TABLE `zseq_groups_lookup` ( -- CREATE TABLE `zseq_groups_units_link` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=2 ; -- -------------------------------------------------------- @@ -1772,9 +1690,9 @@ CREATE TABLE `zseq_groups_units_link` ( -- CREATE TABLE `zseq_help` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=99 ; -- -------------------------------------------------------- @@ -1783,9 +1701,9 @@ CREATE TABLE `zseq_help` ( -- CREATE TABLE `zseq_help_replacement` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=1 ; -- -------------------------------------------------------- @@ -1794,9 +1712,9 @@ CREATE TABLE `zseq_help_replacement` ( -- CREATE TABLE `zseq_links` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=2 ; -- -------------------------------------------------------- @@ -1805,9 +1723,9 @@ CREATE TABLE `zseq_links` ( -- CREATE TABLE `zseq_metadata_lookup` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=2 ; -- -------------------------------------------------------- @@ -1816,9 +1734,9 @@ CREATE TABLE `zseq_metadata_lookup` ( -- CREATE TABLE `zseq_metadata_lookup_tree` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=1 ; -- -------------------------------------------------------- @@ -1827,9 +1745,9 @@ CREATE TABLE `zseq_metadata_lookup_tree` ( -- CREATE TABLE `zseq_mime_types` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=142 ; -- -------------------------------------------------------- @@ -1838,9 +1756,9 @@ CREATE TABLE `zseq_mime_types` ( -- CREATE TABLE `zseq_news` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=2 ; -- -------------------------------------------------------- @@ -1849,9 +1767,9 @@ CREATE TABLE `zseq_news` ( -- CREATE TABLE `zseq_notifications` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=1 ; -- -------------------------------------------------------- @@ -1860,9 +1778,9 @@ CREATE TABLE `zseq_notifications` ( -- CREATE TABLE `zseq_organisations_lookup` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=2 ; -- -------------------------------------------------------- @@ -1871,9 +1789,9 @@ CREATE TABLE `zseq_organisations_lookup` ( -- CREATE TABLE `zseq_permission_assignments` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=4 ; -- -------------------------------------------------------- @@ -1882,9 +1800,9 @@ CREATE TABLE `zseq_permission_assignments` ( -- CREATE TABLE `zseq_permission_descriptors` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=3 ; -- -------------------------------------------------------- @@ -1893,9 +1811,9 @@ CREATE TABLE `zseq_permission_descriptors` ( -- CREATE TABLE `zseq_permission_dynamic_conditions` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=1 ; -- -------------------------------------------------------- @@ -1904,9 +1822,9 @@ CREATE TABLE `zseq_permission_dynamic_conditions` ( -- CREATE TABLE `zseq_permission_lookup_assignments` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=7 ; -- -------------------------------------------------------- @@ -1915,9 +1833,9 @@ CREATE TABLE `zseq_permission_lookup_assignments` ( -- CREATE TABLE `zseq_permission_lookups` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=3 ; -- -------------------------------------------------------- @@ -1926,9 +1844,9 @@ CREATE TABLE `zseq_permission_lookups` ( -- CREATE TABLE `zseq_permission_objects` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=2 ; -- -------------------------------------------------------- @@ -1937,53 +1855,53 @@ CREATE TABLE `zseq_permission_objects` ( -- CREATE TABLE `zseq_permissions` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=4 ; -- -------------------------------------------------------- -- --- Table structure for table `zseq_role_allocations` +-- Table structure for table `zseq_plugins` -- -CREATE TABLE `zseq_role_allocations` ( - `id` int(10) unsigned NOT NULL auto_increment, +CREATE TABLE `zseq_plugins` ( + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- --- Table structure for table `zseq_roles` +-- Table structure for table `zseq_role_allocations` -- -CREATE TABLE `zseq_roles` ( - `id` int(10) unsigned NOT NULL auto_increment, +CREATE TABLE `zseq_role_allocations` ( + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- --- Table structure for table `zseq_saved_searches` +-- Table structure for table `zseq_roles` -- -CREATE TABLE `zseq_saved_searches` ( - `id` int(10) unsigned NOT NULL auto_increment, +CREATE TABLE `zseq_roles` ( + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=2 ; -- -------------------------------------------------------- -- --- Table structure for table `zseq_search_document_user_link` +-- Table structure for table `zseq_saved_searches` -- -CREATE TABLE `zseq_search_document_user_link` ( - `id` int(10) unsigned NOT NULL auto_increment, +CREATE TABLE `zseq_saved_searches` ( + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=1 ; -- -------------------------------------------------------- @@ -1992,9 +1910,9 @@ CREATE TABLE `zseq_search_document_user_link` ( -- CREATE TABLE `zseq_status_lookup` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=5 ; -- -------------------------------------------------------- @@ -2003,9 +1921,9 @@ CREATE TABLE `zseq_status_lookup` ( -- CREATE TABLE `zseq_system_settings` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=4 ; -- -------------------------------------------------------- @@ -2014,9 +1932,9 @@ CREATE TABLE `zseq_system_settings` ( -- CREATE TABLE `zseq_time_period` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=2 ; -- -------------------------------------------------------- @@ -2025,9 +1943,9 @@ CREATE TABLE `zseq_time_period` ( -- CREATE TABLE `zseq_time_unit_lookup` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=4 ; -- -------------------------------------------------------- @@ -2036,9 +1954,9 @@ CREATE TABLE `zseq_time_unit_lookup` ( -- CREATE TABLE `zseq_units_lookup` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=2 ; -- -------------------------------------------------------- @@ -2047,9 +1965,9 @@ CREATE TABLE `zseq_units_lookup` ( -- CREATE TABLE `zseq_units_organisations_link` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=2 ; -- -------------------------------------------------------- @@ -2058,9 +1976,9 @@ CREATE TABLE `zseq_units_organisations_link` ( -- CREATE TABLE `zseq_upgrades` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=51 ; -- -------------------------------------------------------- @@ -2069,9 +1987,9 @@ CREATE TABLE `zseq_upgrades` ( -- CREATE TABLE `zseq_users` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=4 ; -- -------------------------------------------------------- @@ -2080,42 +1998,9 @@ CREATE TABLE `zseq_users` ( -- CREATE TABLE `zseq_users_groups_link` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; - --- -------------------------------------------------------- - --- --- Table structure for table `zseq_web_documents` --- - -CREATE TABLE `zseq_web_documents` ( - `id` int(10) unsigned NOT NULL auto_increment, - PRIMARY KEY (`id`) -) TYPE=MyISAM ; - --- -------------------------------------------------------- - --- --- Table structure for table `zseq_web_documents_status_lookup` --- - -CREATE TABLE `zseq_web_documents_status_lookup` ( - `id` int(10) unsigned NOT NULL auto_increment, - PRIMARY KEY (`id`) -) TYPE=MyISAM ; - --- -------------------------------------------------------- - --- --- Table structure for table `zseq_web_sites` --- - -CREATE TABLE `zseq_web_sites` ( - `id` int(10) unsigned NOT NULL auto_increment, - PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=4 ; -- -------------------------------------------------------- @@ -2124,9 +2009,9 @@ CREATE TABLE `zseq_web_sites` ( -- CREATE TABLE `zseq_workflow_states` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=1 ; -- -------------------------------------------------------- @@ -2135,9 +2020,9 @@ CREATE TABLE `zseq_workflow_states` ( -- CREATE TABLE `zseq_workflow_transitions` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) TYPE=MyISAM ; +) TYPE=MyISAM AUTO_INCREMENT=1 ; -- -------------------------------------------------------- @@ -2146,18 +2031,9 @@ CREATE TABLE `zseq_workflow_transitions` ( -- CREATE TABLE `zseq_workflows` ( - `id` int(10) unsigned NOT NULL auto_increment, - PRIMARY KEY (`id`) -) TYPE=MyISAM ; - - -CREATE TABLE `zseq_plugins` ( - `id` int(10) unsigned NOT NULL auto_increment, + `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) ENGINE=MyISAM; - - - +) TYPE=MyISAM AUTO_INCREMENT=1 ; -- -- Constraints for dumped tables @@ -2173,8 +2049,16 @@ ALTER TABLE `document_fields` -- Constraints for table `document_fields_link` -- ALTER TABLE `document_fields_link` - ADD CONSTRAINT `document_fields_link_ibfk_2` FOREIGN KEY (`document_field_id`) REFERENCES `document_fields` (`id`) ON DELETE CASCADE, - ADD CONSTRAINT `document_fields_link_ibfk_1` FOREIGN KEY (`document_id`) REFERENCES `documents` (`id`) ON DELETE CASCADE; + ADD CONSTRAINT `document_fields_link_ibfk_2` FOREIGN KEY (`document_field_id`) REFERENCES `document_fields` (`id`) ON DELETE CASCADE; + +-- +-- Constraints for table `document_metadata_version` +-- +ALTER TABLE `document_metadata_version` + ADD CONSTRAINT `document_metadata_version_ibfk_4` FOREIGN KEY (`document_id`) REFERENCES `documents` (`id`) ON DELETE CASCADE, + ADD CONSTRAINT `document_metadata_version_ibfk_5` FOREIGN KEY (`document_type_id`) REFERENCES `document_types_lookup` (`id`), + ADD CONSTRAINT `document_metadata_version_ibfk_6` FOREIGN KEY (`status_id`) REFERENCES `status_lookup` (`id`), + ADD CONSTRAINT `document_metadata_version_ibfk_7` FOREIGN KEY (`version_creator_id`) REFERENCES `users` (`id`); -- -- Constraints for table `document_type_fieldsets_link` diff --git a/sql/mysql/upgrade/2.99.2/1-constraints.sql b/sql/mysql/upgrade/2.99.2/1-constraints.sql index 9e2b1ed..06cdbf1 100644 --- a/sql/mysql/upgrade/2.99.2/1-constraints.sql +++ b/sql/mysql/upgrade/2.99.2/1-constraints.sql @@ -1,3 +1,4 @@ +SET FOREIGN_KEY_CHECKS=0; ALTER TABLE `document_type_fieldsets_link` ADD INDEX `document_type_id` (`document_type_id`); ALTER TABLE `document_type_fieldsets_link` ADD INDEX `fieldset_id` (`fieldset_id`); ALTER TABLE `document_type_fieldsets_link` ADD CONSTRAINT `document_type_fieldsets_link_ibfk_1` FOREIGN KEY (`document_type_id`) REFERENCES `document_types_lookup` (`id`) ON DELETE CASCADE; @@ -35,3 +36,4 @@ ALTER TABLE `workflow_transitions` ADD CONSTRAINT `workflow_transitions_ibfk_46` ALTER TABLE `workflow_transitions` ADD CONSTRAINT `workflow_transitions_ibfk_47` FOREIGN KEY (`guard_permission_id`) REFERENCES `permissions` (`id`) ON DELETE SET NULL; ALTER TABLE `workflow_transitions` ADD CONSTRAINT `workflow_transitions_ibfk_49` FOREIGN KEY (`guard_role_id`) REFERENCES `roles` (`id`) ON DELETE SET NULL; ALTER TABLE `workflow_transitions` ADD CONSTRAINT `workflow_transitions_ibfk_45` FOREIGN KEY (`workflow_id`) REFERENCES `workflows` (`id`) ON DELETE CASCADE; +SET FOREIGN_KEY_CHECKS=1; diff --git a/sql/mysql/upgrade/2.99.2/permission_by_user_and_roles.sql b/sql/mysql/upgrade/2.99.2/permission_by_user_and_roles.sql index 6220f74..ba4fa6c 100644 --- a/sql/mysql/upgrade/2.99.2/permission_by_user_and_roles.sql +++ b/sql/mysql/upgrade/2.99.2/permission_by_user_and_roles.sql @@ -1,3 +1,4 @@ +SET FOREIGN_KEY_CHECKS=0; CREATE TABLE `permission_descriptor_roles` ( `descriptor_id` int(11) NOT NULL default '0', `role_id` int(11) NOT NULL default '0', @@ -15,3 +16,4 @@ CREATE TABLE `permission_descriptor_users` ( KEY `user_id` (`user_id`), CONSTRAINT `permission_descriptor_users_ibfk_1` FOREIGN KEY (`descriptor_id`) REFERENCES `permission_descriptors` (`id`) ON DELETE CASCADE, CONSTRAINT `permission_descriptor_users_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ) TYPE=InnoDB; +SET FOREIGN_KEY_CHECKS=1; diff --git a/sql/mysql/upgrade/2.99.6/table_cleanup.sql b/sql/mysql/upgrade/2.99.6/table_cleanup.sql index 0f85512..1fa3710 100644 --- a/sql/mysql/upgrade/2.99.6/table_cleanup.sql +++ b/sql/mysql/upgrade/2.99.6/table_cleanup.sql @@ -1,8 +1,17 @@ -- Drop unused tables +DROP TABLE IF EXISTS `browse_criteria`; +DROP TABLE IF EXISTS `dependant_document_instance`; +DROP TABLE IF EXISTS `dependant_document_template`; +DROP TABLE IF EXISTS `groups_folders_approval_link`; +DROP TABLE IF EXISTS `groups_folders_link`; DROP TABLE IF EXISTS `metadata_lookup_condition`; DROP TABLE IF EXISTS `metadata_lookup_condition_chain`; DROP TABLE IF EXISTS `zseq_metadata_lookup_condition`; DROP TABLE IF EXISTS `zseq_metadata_lookup_condition_chain`; +DROP TABLE IF EXISTS `zseq_search_document_user_link`; +DROP TABLE IF EXISTS `zseq_web_documents`; +DROP TABLE IF EXISTS `zseq_web_documents_status_lookup`; +DROP TABLE IF EXISTS `zseq_web_sites`; -- Make sure sequence tables are MyISAM to avoid transaction-safety. ALTER TABLE `zseq_active_sessions` ENGINE=MyISAM; @@ -49,7 +58,6 @@ ALTER TABLE `zseq_permission_lookups` ENGINE=MyISAM; ALTER TABLE `zseq_permission_objects` ENGINE=MyISAM; ALTER TABLE `zseq_permissions` ENGINE=MyISAM; ALTER TABLE `zseq_roles` ENGINE=MyISAM; -ALTER TABLE `zseq_search_document_user_link` ENGINE=MyISAM; ALTER TABLE `zseq_status_lookup` ENGINE=MyISAM; ALTER TABLE `zseq_system_settings` ENGINE=MyISAM; ALTER TABLE `zseq_time_period` ENGINE=MyISAM; @@ -59,6 +67,46 @@ ALTER TABLE `zseq_units_organisations_link` ENGINE=MyISAM; ALTER TABLE `zseq_upgrades` ENGINE=MyISAM; ALTER TABLE `zseq_users` ENGINE=MyISAM; ALTER TABLE `zseq_users_groups_link` ENGINE=MyISAM; -ALTER TABLE `zseq_web_documents` ENGINE=MyISAM; -ALTER TABLE `zseq_web_documents_status_lookup` ENGINE=MyISAM; -ALTER TABLE `zseq_web_sites` ENGINE=MyISAM; + +ALTER TABLE `active_sessions` TYPE=InnoDB; +ALTER TABLE `archive_restoration_request` TYPE=InnoDB; +ALTER TABLE `archiving_settings` TYPE=InnoDB; +ALTER TABLE `archiving_type_lookup` TYPE=InnoDB; +ALTER TABLE `data_types` TYPE=InnoDB; +ALTER TABLE `discussion_comments` TYPE=InnoDB; +ALTER TABLE `discussion_threads` TYPE=InnoDB; +ALTER TABLE `document_archiving_link` TYPE=InnoDB; +ALTER TABLE `document_fields` TYPE=InnoDB; +ALTER TABLE `document_fields_link` TYPE=InnoDB; +ALTER TABLE `document_link` TYPE=InnoDB; +ALTER TABLE `document_subscriptions` TYPE=InnoDB; +ALTER TABLE `document_transaction_types_lookup` TYPE=InnoDB; +ALTER TABLE `document_transactions` TYPE=InnoDB; +ALTER TABLE `document_type_fields_link` TYPE=InnoDB; +ALTER TABLE `document_types_lookup` TYPE=InnoDB; +ALTER TABLE `documents` TYPE=InnoDB; +ALTER TABLE `folder_doctypes_link` TYPE=InnoDB; +ALTER TABLE `folder_subscriptions` TYPE=InnoDB; +ALTER TABLE `folders` TYPE=InnoDB; +ALTER TABLE `folders_users_roles_link` TYPE=InnoDB; +ALTER TABLE `groups_lookup` TYPE=InnoDB; +ALTER TABLE `groups_units_link` TYPE=InnoDB; +ALTER TABLE `help` TYPE=InnoDB; +ALTER TABLE `links` TYPE=InnoDB; +ALTER TABLE `metadata_lookup` TYPE=InnoDB; +ALTER TABLE `mime_types` TYPE=InnoDB; +ALTER TABLE `news` TYPE=InnoDB; +ALTER TABLE `organisations_lookup` TYPE=InnoDB; +ALTER TABLE `roles` TYPE=InnoDB; +ALTER TABLE `status_lookup` TYPE=InnoDB; +ALTER TABLE `system_settings` TYPE=InnoDB; +ALTER TABLE `time_period` TYPE=InnoDB; +ALTER TABLE `time_unit_lookup` TYPE=InnoDB; +ALTER TABLE `units_lookup` TYPE=InnoDB; +ALTER TABLE `units_organisations_link` TYPE=InnoDB; +ALTER TABLE `users` TYPE=InnoDB; +ALTER TABLE `users_groups_link` TYPE=InnoDB; +ALTER TABLE `web_documents` TYPE=InnoDB; +ALTER TABLE `web_documents_status_lookup` TYPE=InnoDB; +ALTER TABLE `web_sites` TYPE=InnoDB; + diff --git a/sql/mysql/upgrade/2.99.7/10-documents_normalisation.sql b/sql/mysql/upgrade/2.99.7/10-documents_normalisation.sql index 997b62e..ba207bf 100644 --- a/sql/mysql/upgrade/2.99.7/10-documents_normalisation.sql +++ b/sql/mysql/upgrade/2.99.7/10-documents_normalisation.sql @@ -1,3 +1,5 @@ + + ALTER TABLE `documents` DROP COLUMN `document_type_id`; # was int(11) NOT NULL default '0' ALTER TABLE `documents` DROP COLUMN `size`; # was bigint(20) NOT NULL default '0' ALTER TABLE `documents` DROP COLUMN `description`; # was varchar(200) NOT NULL default '' @@ -9,6 +11,3 @@ ALTER TABLE `documents` DROP COLUMN `filename`; # was text NOT NULL ALTER TABLE `documents` DROP COLUMN `storage_path`; # was varchar(250) default NULL ALTER TABLE `documents` DROP COLUMN `mime_id`; # was int(11) NOT NULL default '0' ALTER TABLE `documents` DROP COLUMN `name`; # was text NOT NULL -ALTER TABLE `documents` DROP INDEX `fk_document_type_id`; # was INDEX (`document_type_id`) -ALTER TABLE `documents` DROP INDEX `live_document_id`; # was INDEX (`live_document_id`) -ALTER TABLE `documents` DROP INDEX `storage_path`; # was INDEX (`storage_path`) diff --git a/sql/mysql/upgrade/2.99.7/20-fields.sql b/sql/mysql/upgrade/2.99.7/20-fields.sql new file mode 100644 index 0000000..5d73aae --- /dev/null +++ b/sql/mysql/upgrade/2.99.7/20-fields.sql @@ -0,0 +1,4 @@ +SET FOREIGN_KEY_CHECKS=0; +ALTER TABLE `document_fields_link` DROP FOREIGN KEY `document_fields_link_ibfk_1`; +ALTER TABLE document_fields_link DROP COLUMN document_id; +SET FOREIGN_KEY_CHECKS=1; diff --git a/sql/mysql/upgrade/2.99.7/documents_normalisation.sql b/sql/mysql/upgrade/2.99.7/documents_normalisation.sql index 8737be7..68f4e34 100644 --- a/sql/mysql/upgrade/2.99.7/documents_normalisation.sql +++ b/sql/mysql/upgrade/2.99.7/documents_normalisation.sql @@ -1,3 +1,7 @@ +SET FOREIGN_KEY_CHECKS=0; +ALTER TABLE `document_fields_link` ADD COLUMN `metadata_version_id` int(11) default NULL; +ALTER TABLE `document_fields_link` ADD INDEX `metadata_version_id` (`metadata_version_id`); + CREATE TABLE `document_content_version` ( `id` int(11) NOT NULL default '0', `document_id` int(11) NOT NULL default '0', @@ -10,7 +14,7 @@ CREATE TABLE `document_content_version` ( UNIQUE KEY `id` (`id`), KEY `storage_path` (`storage_path`), KEY `document_id` (`document_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; +) ENGINE=InnoDB; CREATE TABLE `document_metadata_version` ( `id` int(11) NOT NULL default '0', @@ -34,4 +38,18 @@ CREATE TABLE `document_metadata_version` ( CONSTRAINT `document_metadata_version_ibfk_5` FOREIGN KEY (`document_type_id`) REFERENCES `document_types_lookup` (`id`), CONSTRAINT `document_metadata_version_ibfk_6` FOREIGN KEY (`status_id`) REFERENCES `status_lookup` (`id`), CONSTRAINT `document_metadata_version_ibfk_7` FOREIGN KEY (`version_creator_id`) REFERENCES `users` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; +) ENGINE=InnoDB; + +ALTER TABLE `documents` ADD metadata_version_id int(11) default NULL; +ALTER TABLE `documents` ADD INDEX `metadata_version_id` (`metadata_version_id`); + +CREATE TABLE `zseq_document_content_version` ( + `id` int(10) unsigned NOT NULL auto_increment, + PRIMARY KEY (`id`) +) ENGINE=MyISAM; + +CREATE TABLE `zseq_document_metadata_version` ( + `id` int(10) unsigned NOT NULL auto_increment, + PRIMARY KEY (`id`) +) ENGINE=MyISAM; +SET FOREIGN_KEY_CHECKS=1; diff --git a/sql/mysql/upgrade/2.99.7/table_cleanup.sql b/sql/mysql/upgrade/2.99.7/table_cleanup.sql new file mode 100644 index 0000000..1d6cb9f --- /dev/null +++ b/sql/mysql/upgrade/2.99.7/table_cleanup.sql @@ -0,0 +1,44 @@ +SET FOREIGN_KEY_CHECKS=0; +ALTER TABLE `active_sessions` CHANGE COLUMN `session_id` `session_id` char(255) default NULL; # was varchar(255) default NULL +ALTER TABLE `active_sessions` CHANGE COLUMN `ip` `ip` char(30) default NULL; # was varchar(30) default NULL +ALTER TABLE `archiving_type_lookup` CHANGE COLUMN `name` `name` char(100) default NULL; # was varchar(100) default NULL +ALTER TABLE `data_types` CHANGE COLUMN `name` `name` char(255) NOT NULL default ''; # was varchar(255) default NULL +ALTER TABLE `document_fields` CHANGE COLUMN `data_type` `data_type` varchar(100) NOT NULL default ''; # was varchar(100) default NULL +ALTER TABLE `document_fields` CHANGE COLUMN `name` `name` varchar(255) NOT NULL default ''; # was varchar(255) default NULL +ALTER TABLE `document_fields_link` CHANGE COLUMN `value` `value` char(255) NOT NULL default ''; # was varchar(255) default NULL +ALTER TABLE `document_transactions` CHANGE COLUMN `ip` `ip` char(30) default NULL; # was varchar(30) default NULL +ALTER TABLE `document_transactions` CHANGE COLUMN `transaction_namespace` `transaction_namespace` char(255) NOT NULL default 'ktcore.transactions.event'; # was varchar(255) NOT NULL default 'ktcore.transactions.event' +ALTER TABLE `document_transactions` CHANGE COLUMN `comment` `comment` char(255) NOT NULL default ''; # was varchar(255) default NULL +ALTER TABLE `document_transactions` CHANGE COLUMN `filename` `filename` char(255) NOT NULL default ''; # was varchar(255) default NULL +ALTER TABLE `document_transactions` CHANGE COLUMN `version` `version` char(50) default NULL; # was varchar(50) default NULL +ALTER TABLE `document_types_lookup` CHANGE COLUMN `name` `name` char(100) default NULL; # was varchar(100) default NULL +ALTER TABLE `groups_lookup` CHANGE COLUMN `name` `name` char(100) NOT NULL default ''; # was varchar(100) default NULL +ALTER TABLE `help_replacement` DROP COLUMN `title`; # was varchar(255) NOT NULL default '' +ALTER TABLE `help_replacement` CHANGE COLUMN `name` `name` varchar(100) NOT NULL default ''; # was varchar(255) NOT NULL default '' +DROP TABLE IF EXISTS `language_lookup`; +ALTER TABLE `links` CHANGE COLUMN `url` `url` char(100) NOT NULL default ''; # was varchar(100) default NULL +ALTER TABLE `links` CHANGE COLUMN `name` `name` char(100) NOT NULL default ''; # was varchar(100) default NULL +ALTER TABLE `metadata_lookup` CHANGE COLUMN `name` `name` char(255) default NULL; # was varchar(255) default NULL +ALTER TABLE `mime_types` CHANGE COLUMN `filetypes` `filetypes` char(100) NOT NULL default ''; # was varchar(100) default NULL +ALTER TABLE `mime_types` CHANGE COLUMN `mimetypes` `mimetypes` char(100) NOT NULL default ''; # was varchar(100) default NULL +ALTER TABLE `mime_types` CHANGE COLUMN `icon_path` `icon_path` char(255) default NULL; # was varchar(255) default NULL +ALTER TABLE `notifications` CHANGE COLUMN `data_str_1` `data_str_1` varchar(255) default NULL; # was varchar(255) NOT NULL default '' +ALTER TABLE `notifications` CHANGE COLUMN `data_int_2` `data_int_2` int(11) default NULL; # was int(11) NOT NULL default '0' +ALTER TABLE `notifications` CHANGE COLUMN `data_int_1` `data_int_1` int(11) default NULL; # was int(11) NOT NULL default '0' +ALTER TABLE `notifications` CHANGE COLUMN `data_str_2` `data_str_2` varchar(255) default NULL; # was varchar(255) NOT NULL default '' +ALTER TABLE `organisations_lookup` CHANGE COLUMN `name` `name` char(100) NOT NULL default ''; # was varchar(100) default NULL +ALTER TABLE `roles` CHANGE COLUMN `name` `name` char(255) NOT NULL default ''; # was varchar(255) default NULL +ALTER TABLE `status_lookup` CHANGE COLUMN `name` `name` char(255) default NULL; # was varchar(255) default NULL +ALTER TABLE `system_settings` CHANGE COLUMN `value` `value` char(255) NOT NULL default ''; # was varchar(255) default NULL +ALTER TABLE `system_settings` CHANGE COLUMN `name` `name` char(255) NOT NULL default ''; # was varchar(255) default NULL +ALTER TABLE `time_unit_lookup` CHANGE COLUMN `name` `name` char(100) default NULL; # was varchar(100) default NULL +ALTER TABLE `units_lookup` CHANGE COLUMN `name` `name` char(100) NOT NULL default ''; # was varchar(100) default NULL +ALTER TABLE `users` CHANGE COLUMN `password` `password` varchar(255) NOT NULL default ''; # was varchar(255) default NULL +ALTER TABLE `users` CHANGE COLUMN `username` `username` varchar(255) NOT NULL default ''; # was varchar(255) default NULL +ALTER TABLE `users` CHANGE COLUMN `name` `name` varchar(255) NOT NULL default ''; # was varchar(255) default NULL +DROP TABLE IF EXISTS `zseq_groups_folders_approval_link`; +DROP TABLE IF EXISTS `zseq_groups_folders_link`; +DROP TABLE IF EXISTS `web_documents`; +DROP TABLE IF EXISTS `web_documents_status_lookup`; +DROP TABLE IF EXISTS `web_sites`; +SET FOREIGN_KEY_CHECKS=1; diff --git a/tests/document/add.php b/tests/document/add.php index 6a725d1..f64251c 100644 --- a/tests/document/add.php +++ b/tests/document/add.php @@ -13,7 +13,6 @@ $sLocalname = KT_DIR . "/tests/document/dataset1/critique-of-pure-reason.txt"; $sFilename = tempnam("/tmp", "kt_tests_document_add"); copy($sLocalname, $sFilename); -/* $oDocument =& KTDocumentUtil::add($oFolder, "testquickupload.txt", $oUser, array( 'contents' => new KTFSFileLike($sFilename), )); @@ -23,7 +22,6 @@ if (PEAR::isError($oDocument)) { var_dump($oDocument); exit(0); } -*/ if (!file_exists($sFilename)) { copy($sLocalname, $sFilename); @@ -35,11 +33,10 @@ if (PEAR::isError($oDocument)) { var_dump($oDocument); } -/* - $res = KTDocumentUtil::storeContents($oDocument, new KTFSFileLike($sFilename)); var_dump($res); +/* if (file_exists($sFilename)) { unlink($sFilename); } diff --git a/tests/permissions/updatePermissionLookup.php b/tests/permissions/updatePermissionLookup.php index 2b15487..bbee015 100644 --- a/tests/permissions/updatePermissionLookup.php +++ b/tests/permissions/updatePermissionLookup.php @@ -2,6 +2,7 @@ require_once("../../config/dmsDefaults.php"); require_once(KT_LIB_DIR . '/foldermanagement/Folder.inc'); +require_once(KT_LIB_DIR . '/documentmanagement/Document.inc'); require_once(KT_LIB_DIR . '/permissions/permissionutil.inc.php'); error_reporting(E_ALL); @@ -16,7 +17,7 @@ foreach ($aDocuments as $oDocument) { KTPermissionUtil::updatePermissionLookup($oDocument); } */ -$oFolder = Folder::get(18); -KTPermissionUtil::updatePermissionLookup($oFolder); +$oDocument = Document::get(447); +KTPermissionUtil::updatePermissionLookup($oDocument); ?> diff --git a/view.php b/view.php index ec7eee3..2f04bdd 100755 --- a/view.php +++ b/view.php @@ -89,7 +89,7 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { } // we want to grab all the md for this doc, since its faster that way. - $mdlist =& DocumentFieldLink::getList(array('document_id = ?', array($document_id))); + $mdlist =& DocumentFieldLink::getByDocument($oDocument); $field_values = array(); foreach ($mdlist as $oFieldLink) {