diff --git a/config/dmsDefaults.php b/config/dmsDefaults.php
index e0033d7..d0c13e5 100644
--- a/config/dmsDefaults.php
+++ b/config/dmsDefaults.php
@@ -47,7 +47,7 @@ if (defined('DMS_DEFAULTS_INCLUDED'))
}
define('DMS_DEFAULTS_INCLUDED',1);
-define('LATEST_WEBSERVICE_VERSION',2);
+define('LATEST_WEBSERVICE_VERSION',3);
if (function_exists('apd_set_pprof_trace')) {
diff --git a/ktapi/KTAPIConstants.inc.php b/ktapi/KTAPIConstants.inc.php
index 29ef5ff..e0c7409 100644
--- a/ktapi/KTAPIConstants.inc.php
+++ b/ktapi/KTAPIConstants.inc.php
@@ -5,32 +5,32 @@
* KnowledgeTree Community Edition
* Document Management Made Simple
* Copyright (C) 2008, 2009, 2010 KnowledgeTree Inc.
- *
- *
+ *
+ *
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
- *
- * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
+ *
+ * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
* California 94120-7775, or email info@knowledgetree.com.
- *
+ *
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
- *
+ *
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
- * KnowledgeTree" logo and retain the original copyright notice. If the display of the
+ * KnowledgeTree" logo and retain the original copyright notice. If the display of the
* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
- * must display the words "Powered by KnowledgeTree" and retain the original
+ * must display the words "Powered by KnowledgeTree" and retain the original
* copyright notice.
* Contributor( s): ______________________________________
*/
@@ -53,6 +53,7 @@ define('KTAPI_ERROR_SESSION_INVALID', 'The session could not be resolved.');
define('KTAPI_ERROR_PERMISSION_INVALID', 'The permission could not be resolved.');
define('KTAPI_ERROR_FOLDER_INVALID', 'The folder could not be resolved.');
define('KTAPI_ERROR_DOCUMENT_INVALID', 'The document could not be resolved.');
+define('KTAPI_ERROR_VERSION_INVALID', 'The document version could not be resolved.');
define('KTAPI_ERROR_USER_INVALID', 'The user could not be resolved.');
define('KTAPI_ERROR_KTAPI_INVALID', 'The ktapi could not be resolved.');
define('KTAPI_ERROR_INSUFFICIENT_PERMISSIONS', 'The user does not have sufficient permissions to access the resource.');
diff --git a/ktapi/KTAPIDocument.inc.php b/ktapi/KTAPIDocument.inc.php
index 148cf2b..5149704 100644
--- a/ktapi/KTAPIDocument.inc.php
+++ b/ktapi/KTAPIDocument.inc.php
@@ -91,16 +91,17 @@ class KTAPI_Document extends KTAPI_FolderItem
}
/**
- * This is used to get a document based on document id.
+ * This is used to get a document based on document id. Or a version of the document based on the metadata version id
*
* @author KnowledgeTree Team
* @static
* @access public
* @param KTAPI $ktapi The ktapi object
* @param int $documentid The document id
+ * @param int $iMetadataVersionId Optional. The metadata version id
* @return KTAPI_Document The document object
*/
- function &get(&$ktapi, $documentid)
+ function &get(&$ktapi, $documentid, $iMetadataVersionId = null)
{
assert(!is_null($ktapi));
assert(is_a($ktapi, 'KTAPI'));
@@ -108,7 +109,7 @@ class KTAPI_Document extends KTAPI_FolderItem
$documentid += 0;
- $document = &Document::get($documentid);
+ $document = &Document::get($documentid, $iMetadataVersionId);
if (is_null($document) || PEAR::isError($document))
{
return new KTAPI_Error(KTAPI_ERROR_DOCUMENT_INVALID,$document );
@@ -137,6 +138,30 @@ class KTAPI_Document extends KTAPI_FolderItem
}
/**
+ * This is used to get a document based on the document id and the metadata version
+ *
+ * @author KnowledgeTree Team
+ * @static
+ * @access public
+ * @param KTAPI $ktapi The ktapi object
+ * @param int $documentid The document id
+ * @param int $metadataVersion The metadata version (0,1,2)
+ * @return KTAPI_Document The document object
+ */
+ function &get_by_metadata_version(&$ktapi, $documentid, $metadataVersion)
+ {
+ // get the metadata version id
+ $iMetadataVersionId = Document::getMetadataVersionIdFromVersion($documentid, $metadataVersion);
+ if (is_null($iMetadataVersionId) || PEAR::isError($iMetadataVersionId))
+ {
+ return new KTAPI_Error(KTAPI_ERROR_VERSION_INVALID, $iMetadataVersionId );
+ }
+
+ // get the KTAPI_Document object
+ return self::get($ktapi, $documentid, $iMetadataVersionId);
+ }
+
+ /**
* Checks if a document has been deleted
*
* @author KnowledgeTree Team
@@ -2137,13 +2162,14 @@ class KTAPI_Document extends KTAPI_FolderItem
* @author KnowledgeTree Team
* @access public
*/
- function download()
+ function download($version = null)
{
$storage =& KTStorageManagerUtil::getSingleton();
$options = array();
+ $comment = (!is_null($version)) ? 'Document version '.$version.' downloaded' : 'Document downloaded';
$oDocumentTransaction = new DocumentTransaction($this->document, 'Document downloaded', 'ktcore.transactions.download', $aOptions);
- $oDocumentTransaction->create();
+ return $oDocumentTransaction->create();
}
/**
@@ -2241,6 +2267,17 @@ class KTAPI_Document extends KTAPI_FolderItem
}
/**
+ * Get the content version id using the document (content) version - major/minor version
+ *
+ * @param string $version
+ * @return int
+ */
+ function get_content_version_id_from_version($version)
+ {
+ return $this->document->getContentVersionIdFromVersion($version);
+ }
+
+ /**
* This expunges a document from the system.
*
*
diff --git a/ktapi/ktapi.inc.php b/ktapi/ktapi.inc.php
index 882600a..f8a6b96 100644
--- a/ktapi/ktapi.inc.php
+++ b/ktapi/ktapi.inc.php
@@ -870,6 +870,22 @@ class KTAPI
}
/**
+ * This returns a refererence to a document based on document id.
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @param integer $documentid The document id
+ * @param integer $metadataVersion The metadata version of the document (not the id)
+ * @return object $document The KTAPI_Document object
+ */
+ public function &get_document_by_metadata_version($documentid, $metadataVersion)
+ {
+ // Get the document using the metadata version
+ $document = KTAPI_Document::get_by_metadata_version($this, $documentid, $metadataVersion);
+ return $document;
+ }
+
+ /**
* This returns a document type id based on the name or an error object.
*
* @author KnowledgeTree Team
diff --git a/ktwebservice/KTDownloadManager.inc.php b/ktwebservice/KTDownloadManager.inc.php
index 43beb07..5d32657 100644
--- a/ktwebservice/KTDownloadManager.inc.php
+++ b/ktwebservice/KTDownloadManager.inc.php
@@ -9,7 +9,7 @@
* KnowledgeTree Community Edition
* Document Management Made Simple
* Copyright (C) 2008, 2009, 2010 KnowledgeTree Inc.
- *
+ *
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
@@ -76,44 +76,41 @@ class KTDownloadManager
{
$this->session = $session;
}
-
+
/**
* This returns
*
* @access public
* @param KTAPI_Document $document
+ * @param int $content_version_id Optional. The id of the requested content version
* @return string
*/
- function allow_download($document, $content_version = null, $multipart = false) {
+ function allow_download($document, $content_version_id = null, $multipart = false) {
assert ( ! is_null ( $document ) );
-
- $content_version = 0;
+
$filesize = 0;
-
+
if ($document instanceof KTAPI_Document) {
$doc_id = $document->documentid;
- $content_version = $document->document->getContentVersionId ();
+ //$content_version_id = (is_numeric($content_version_id)) ? $content_version_id : $document->document->getContentVersionId();
$filesize = $document->document->getFileSize ();
} else if ($document instanceof Document || $document instanceof DocumentProxy) {
$doc_id = $document->getId ();
- $content_version = $document->getContentVersionId ();
+ //$content_version_id = (is_numeric($content_version_id)) ? $content_version_id : $document->getContentVersionId();
$filesize = $document->getFileSize ();
} else if (is_numeric ( $document )) {
$doc_id = $document;
} else
die ( 'gracefully' );
-
- //assert(is_a($document, 'KTAPI_Document'));
-
-
- $hash = sha1 ( "$doc_id $this->session $this->random" );
-
- $id = DBUtil::autoInsert ( 'download_files', array ('document_id' => $doc_id, 'session' => $this->session, 'download_date' => date ( 'Y-m-d H:i:s' ), 'content_version' => $content_version, 'filesize' => $filesize, 'hash' => $hash ), array ('noid' => true ) );
-
- return $multipart?$this->build_multipart_url( $hash, $doc_id ):$this->build_url ( $hash, $doc_id );
+
+ $hash = sha1 ( "$doc_id $content_version_id $this->session $this->random" );
+
+ $id = DBUtil::autoInsert ( 'download_files', array ('document_id' => $doc_id, 'session' => $this->session, 'download_date' => date ( 'Y-m-d H:i:s' ), 'content_version' => $content_version_id, 'filesize' => $filesize, 'hash' => $hash ), array ('noid' => true ) );
+
+ return $multipart ? $this->build_multipart_url( $hash, $doc_id ) : $this->build_url ( $hash, $doc_id );
}
-
-
+
+
/**
* This returns the url used to download a document.
*
@@ -125,21 +122,24 @@ class KTDownloadManager
function build_url($hash, $documentid) {
return $this->download_url . "?code=$hash&d=$documentid&u=$this->session";
}
-
+
function build_multipart_url($hash, $documentId) {
-// return '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@';
return $this->multipart_download_url . "?code=$hash&d=$documentId&u=$this->session";
}
-
/**
* This starts a download.
*
* @access public
+ *
+ * @param int $document_id
+ * @param string $hash
+ * @param string $apptype
+ * @return mixed
*/
- function download($document_id, $hash, $version = null, $apptype = 'ws')
+ function download($document_id, $hash, $apptype = 'ws')
{
- $sql = "SELECT 1 FROM download_files WHERE hash=? AND session=? AND document_id=?";
+ $sql = "SELECT content_version FROM download_files WHERE hash=? AND session=? AND document_id=?";
$rows = DBUtil::getResultArray(array($sql, array($hash, $this->session, $document_id)));
if (PEAR::isError($rows))
{
@@ -151,11 +151,14 @@ class KTDownloadManager
return new PEAR_Error('Invalid session.');
}
+ // Get the content version id
+ $content_version_id = $rows[0]['content_version'];
+
// If document is being downloaded by an external user bypass the session checking
$check = strstr($this->session, 'ktext_'.$document_id);
if($check == 0 && $check !== false){
// Use external download function
- return $this->download_ext($document_id, $hash, $version = null);
+ return $this->download_ext($document_id, $hash, $content_version_id);
}
$storage =& KTStorageManagerUtil::getSingleton();
@@ -173,11 +176,9 @@ class KTDownloadManager
return $document;
}
- if (!empty($version))
+ if (!empty($content_version_id))
{
- $version = KTDocumentContentVersion::get($version);
-
- $res = $storage->downloadVersion($document->document, $version);
+ $res = $storage->downloadVersion($document->document, $content_version_id);
}
else
{
@@ -193,8 +194,8 @@ class KTDownloadManager
return true;
}
-
- function download_ext($document_id, $hash, $version = null)
+
+ function download_ext($document_id, $hash, $content_version_id = null)
{
$storage =& KTStorageManagerUtil::getSingleton();
$document = Document::get($document_id);
@@ -203,11 +204,9 @@ class KTDownloadManager
return $document;
}
- if (!empty($version))
+ if (!empty($content_version_id))
{
- $version = KTDocumentContentVersion::get($version);
-
- $res = $storage->downloadVersion($document, $version);
+ $res = $storage->downloadVersion($document, $content_version_id);
}
else
{
@@ -237,4 +236,4 @@ class KTDownloadManager
DBUtil::runQuery($sql);
}
}
-?>
+?>
\ No newline at end of file
diff --git a/ktwebservice/download.php b/ktwebservice/download.php
index 05d413b..6965e84 100644
--- a/ktwebservice/download.php
+++ b/ktwebservice/download.php
@@ -7,7 +7,7 @@
* KnowledgeTree Community Edition
* Document Management Made Simple
* Copyright (C) 2008, 2009, 2010 KnowledgeTree Inc.
- *
+ *
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
@@ -73,7 +73,7 @@ require_once('KTDownloadManager.inc.php');
$download_manager = new KTDownloadManager();
$download_manager->set_session($session);
-$response = $download_manager->download($document_id, $hash, null, $apptype);
+$response = $download_manager->download($document_id, $hash, $apptype);
if (PEAR::isError($response))
{
$msg = urlencode($response->getMessage());
diff --git a/ktwebservice/webservice.php b/ktwebservice/webservice.php
index 70a9926..5445c04 100644
--- a/ktwebservice/webservice.php
+++ b/ktwebservice/webservice.php
@@ -60,8 +60,6 @@ if (defined('HAS_SEARCH_FUNCTIONALITY'))
require_once(KT_DIR . '/search2/search/search.inc.php');
}
-// TODO: allow downloading of metadata versions
-// TODO: allow downloading of document versions
// TODO: chunking search results
// TODO: add basic permissions management - add permissions to folder based on user/groups
// TODO: refactor!!! download manager, split this file into a few smaller ones, etc
@@ -72,7 +70,7 @@ if (defined('HAS_SEARCH_FUNCTIONALITY'))
// TODO: ktwsapi/php must be made compatible with v2/v3
// TODO: subscriptions/notifications
-// NOTE: some features are not implemented yet. most expected for v3. e.g. oem_document_no, custom_document_no, download($version)., get_metadata($version)
+// NOTE: some features are not implemented yet. most expected for v3. e.g. oem_document_no, custom_document_no
// Status Codes as defined in the specification.
@@ -97,7 +95,7 @@ define('KTWS_ERR_DB_PROBLEM', 99);
if (!defined('LATEST_WEBSERVICE_VERSION'))
{
- define('LATEST_WEBSERVICE_VERSION', 2);
+ define('LATEST_WEBSERVICE_VERSION', 3);
}
function bool2str($bool)
@@ -2944,12 +2942,13 @@ class KTWebService
*
* @param string $session_id
* @param int $document_id
+ * @param string $version The document (content) version - "major version" . "minor version"
* @return kt_response. status_code can be KTWS_ERR_INVALID_SESSION, KTWS_ERR_INVALID_DOCUMENT or KTWS_SUCCESS
*/
function download_document($session_id, $document_id, $version=null)
{
- $this->debug("download_document('$session_id',$document_id)");
+ $this->debug("download_document('$session_id',$document_id, '$version')");
$kt = &$this->get_ktapi($session_id );
if (is_array($kt))
@@ -2968,11 +2967,23 @@ class KTWebService
return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response);
}
- $result = $document->download();
+ $content_version_id = null;
+ if(!empty($version)){
+ // Get the content version id for the given document version
+ $content_version_id = $document->get_content_version_id_from_version($version);
+ if (PEAR::isError($content_version_id))
+ {
+ $response['message'] = $result->getMessage();
+ $this->debug("download_document - cannot get version $version - " . $result->getMessage(), $session_id);
+ return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response);
+ }
+ }
+
+ $result = $document->download($version);
if (PEAR::isError($result))
{
$response['message'] = $result->getMessage();
- $this->debug("download_document - cannot download - " . $result->getMessage(), $session_id);
+ $this->debug("download_document - cannot download (version $version) - " . $result->getMessage(), $session_id);
return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response);
}
@@ -2980,7 +2991,7 @@ class KTWebService
$download_manager = new KTDownloadManager();
$download_manager->set_session($session->session);
$download_manager->cleanup();
- $url = $download_manager->allow_download($document);
+ $url = $download_manager->allow_download($document, $content_version_id);
$response['status_code'] = KTWS_SUCCESS;
$response['message'] = $url;
@@ -3016,7 +3027,19 @@ class KTWebService
return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response);
}
- $result = $document->download();
+ $content_version_id = null;
+ if(!empty($version)){
+ // Get the content version id for the given document version
+ $content_version_id = $document->get_content_version_id_from_version($version);
+ if (PEAR::isError($content_version_id))
+ {
+ $response['message'] = $result->getMessage();
+ $this->debug("download_document - cannot get version $version - " . $result->getMessage(), $session_id);
+ return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response);
+ }
+ }
+
+ $result = $document->download($version);
if (PEAR::isError($result))
{
$response['message'] = $result->getMessage();
@@ -3024,24 +3047,33 @@ class KTWebService
return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response);
}
- $content='';
+ $content = '';
+ $oStorage =& KTStorageManagerUtil::getSingleton();
- $document = $document->document;
+ // for a specified version
+ if(is_numeric($content_version_id)){
+ $filename = $oStorage->temporaryFileForVersion($content_version_id);
- $oStorage =& KTStorageManagerUtil::getSingleton();
- $filename = $oStorage->temporaryFile($document);
-
- $fp=fopen($filename,'rb');
- if ($fp === false)
- {
+ if(!$filename){
$response['message'] = 'The file is not in the storage system. Please contact an administrator!';
- $this->debug("download_small_document - cannot write $filename", $session_id);
+ $this->debug("download_small_document - $filename cannot be found in the storage system", $session_id);
return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response);
- }
- $content = fread($fp, filesize($filename));
- fclose($fp);
- $content = base64_encode($content);
+ }
+ }else{
+ $document = $document->document;
+ $filename = $oStorage->temporaryFile($document);
+ }
+ $fp=fopen($filename,'rb');
+ if ($fp === false)
+ {
+ $response['message'] = 'The file is not in the storage system. Please contact an administrator!';
+ $this->debug("download_small_document - cannot read $filename", $session_id);
+ return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response);
+ }
+ $content = fread($fp, filesize($filename));
+ fclose($fp);
+ $content = base64_encode($content);
$response['status_code'] = KTWS_SUCCESS;
$response['message'] = $content;
@@ -3743,9 +3775,9 @@ class KTWebService
* @param int $document_id
* @return kt_metadata_response
*/
- function get_document_metadata($session_id,$document_id)
+ function get_document_metadata($session_id, $document_id, $version = null)
{
- $this->debug("get_document_metadata('$session_id',$document_id)");
+ $this->debug("get_document_metadata('$session_id',$document_id, $version)");
$kt = &$this->get_ktapi($session_id );
if (is_array($kt))
@@ -3755,7 +3787,12 @@ class KTWebService
$response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT);
- $document = &$kt->get_document_by_id($document_id);
+ if(is_numeric($version)){
+ $document = &$kt->get_document_by_metadata_version($document_id, $version);
+ }else {
+ $document = &$kt->get_document_by_id($document_id);
+ }
+
if (PEAR::isError($document))
{
$response['message'] = $document->getMessage();
diff --git a/lib/documentmanagement/Document.inc b/lib/documentmanagement/Document.inc
index 82abff1..13c2cba 100644
--- a/lib/documentmanagement/Document.inc
+++ b/lib/documentmanagement/Document.inc
@@ -5,7 +5,7 @@
* KnowledgeTree Community Edition
* Document Management Made Simple
* Copyright (C) 2008, 2009, 2010 KnowledgeTree Inc.
- *
+ *
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
@@ -169,7 +169,7 @@ class Document {
function getStoragePath() { return $this->_oDocumentContentVersion->getStoragePath(); }
function setStoragePath($sNewValue) { $this->_oDocumentContentVersion->setStoragePath($sNewValue); }
-
+
/**
@@ -679,6 +679,50 @@ class Document {
}
// }}}
+ // {{{ getContentVersionIdFromVersion
+ function getContentVersionIdFromVersion($version)
+ {
+ $aVersion = explode('.', $version);
+ $major = $aVersion[0];
+ $minor = $aVersion[1];
+
+ $doc_id = $this->iId;
+
+ $query = "select id from document_content_version where document_id = $doc_id and major_version = $major and minor_version = $minor";
+
+ $result = DBUtil::getOneResultKey($query, 'id');
+
+ if(empty($result)){
+ return PEAR::raiseError("Requested content version, $version, does not exist.");
+ }
+
+ if(PEAR::isError($result)){
+ return $result;
+ }
+
+ return $result;
+ }
+ // }}}
+
+ // {{{ getMetadataVersionIdFromVersion
+ static function getMetadataVersionIdFromVersion($doc_id, $version)
+ {
+ $query = "select id from document_metadata_version where document_id = $doc_id and metadata_version = $version";
+
+ $result = DBUtil::getOneResultKey($query, 'id');
+
+ if(empty($result)){
+ return PEAR::raiseError("Requested metadata version, $version, does not exist.");
+ }
+
+ if(PEAR::isError($result)){
+ return $result;
+ }
+
+ return $result;
+ }
+ // }}}
+
// {{{ delete
function delete() {
$this->_oDocumentCore->setMetadataVersionId(null);
diff --git a/lib/documentmanagement/documentmetadataversion.inc.php b/lib/documentmanagement/documentmetadataversion.inc.php
index 2f9c766..e1079f8 100644
--- a/lib/documentmanagement/documentmetadataversion.inc.php
+++ b/lib/documentmanagement/documentmetadataversion.inc.php
@@ -5,32 +5,32 @@
* KnowledgeTree Community Edition
* Document Management Made Simple
* Copyright (C) 2008, 2009, 2010 KnowledgeTree Inc.
- *
- *
+ *
+ *
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
- *
- * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
+ *
+ * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
* California 94120-7775, or email info@knowledgetree.com.
- *
+ *
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
- *
+ *
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
- * KnowledgeTree" logo and retain the original copyright notice. If the display of the
+ * KnowledgeTree" logo and retain the original copyright notice. If the display of the
* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
- * must display the words "Powered by KnowledgeTree" and retain the original
+ * must display the words "Powered by KnowledgeTree" and retain the original
* copyright notice.
* Contributor( s): ______________________________________
*
@@ -73,7 +73,7 @@ class KTDocumentMetadataVersion extends KTEntity {
var $iWorkflowStateId;
var $_aFieldToSelect;
-
+
public static $_versionFields = null;
// {{{ getters/setters
@@ -101,11 +101,11 @@ class KTDocumentMetadataVersion extends KTEntity {
function getWorkflowStateId() { return $this->iWorkflowStateId; }
function setWorkflowStateId($mValue) { $this->iWorkflowStateId = $mValue; }
// }}}
-
+
function __construct() {
$this->_aFieldToSelect = KTDocumentMetaDataVersion::getFieldsToSelect();
}
-
+
function getFieldsToSelect() {
if(self::$_versionFields == null) {
$sTable = KTUtil::getTableName('document_metadata_version');
@@ -116,24 +116,24 @@ class KTDocumentMetadataVersion extends KTEntity {
}
self::$_versionFields = $result;
}
- return self::$_versionFields;
+ return self::$_versionFields;
}
-
+
function getFieldType($dbType) {
/* Integer test */
if(strpos($dbType, "int") !== FALSE) {
return "i";
}
-
+
/* Time test */
if(strpos($dbType, "time") !== FALSE) {
return "d";
}
-
+
/* Default */
return "s";
}
-
+
function &createFromArray($aOptions) {
return KTEntityUtil::createFromArray('KTDocumentMetadataVersion', $aOptions);
@@ -163,7 +163,7 @@ class KTDocumentMetadataVersion extends KTEntity {
'document_id' => $iDocumentId,
), array(
'multi' => true,
- 'orderby' => 'version_created DESC',
+ 'orderby' => 'version_created DESC, metadata_version DESC',
));
}
diff --git a/lib/storage/ondiskhashedstoragemanager.inc.php b/lib/storage/ondiskhashedstoragemanager.inc.php
index 8e1b8eb..e980853 100644
--- a/lib/storage/ondiskhashedstoragemanager.inc.php
+++ b/lib/storage/ondiskhashedstoragemanager.inc.php
@@ -8,7 +8,7 @@
* KnowledgeTree Community Edition
* Document Management Made Simple
* Copyright (C) 2008, 2009, 2010 KnowledgeTree Inc.
- *
+ *
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
@@ -176,6 +176,20 @@ class KTOnDiskHashedStorageManager extends KTStorageManager {
return sprintf("%s/%s", $oConfig->get('urls/documentRoot'), $this->getPath($oDocument));
}
+ function temporaryFileForVersion($iVersionId) {
+ $oConfig =& KTConfig::getSingleton();
+
+ // get path to the content version
+ $oContentVersion = KTDocumentContentVersion::get($iVersionId);
+ $sPath = sprintf("%s/%s", $oConfig->get('urls/documentRoot'), $this->getPath($oContentVersion));
+
+ // Ensure the file exists
+ if (file_exists($sPath)) {
+ return $sPath;
+ }
+ return false;
+ }
+
function freeTemporaryFile($sPath) {
// Storage uses file-on-filesystem for temporaryFile
return;
diff --git a/plugins/ktcore/KTWidgets.php b/plugins/ktcore/KTWidgets.php
index 35d8dab..5ba2dd4 100755
--- a/plugins/ktcore/KTWidgets.php
+++ b/plugins/ktcore/KTWidgets.php
@@ -1165,6 +1165,8 @@ class KTCoreImageSelectWidget extends KTWidget {
$oTemplate = $oTemplating->loadTemplate('ktcore/forms/widgets/base');
$this->aJavascript[] = 'thirdpartyjs/jquery/jquery-1.3.2.js';
+ $this->aJavascript[] = 'thirdpartyjs/jquery/plugins/selectimage/jquery.selectimage.js';
+ $this->aJavascript[] = 'resources/js/kt_selectimage.js';
if (!empty($this->aJavascript)) {
// grab our inner page.
@@ -1172,14 +1174,15 @@ class KTCoreImageSelectWidget extends KTWidget {
$oPage->requireJSResources($this->aJavascript);
}
- $this->aCSS[] = 'resources/css/kt_imageselect.css';
+ //$this->aCSS[] = 'resources/css/kt_imageselect.css';
+ $this->aCSS[] = 'thirdpartyjs/jquery/plugins/selectimage/css/selectimage.css';
if (!empty($this->aCSS)) {
// grab our inner page.
$oPage =& $GLOBALS['main'];
$oPage->requireCSSResources($this->aCSS);
}
-
+
$widget_content = $this->getWidget();
$aTemplateData = array(
diff --git a/resources/js/kt_selectimage.js b/resources/js/kt_selectimage.js
new file mode 100755
index 0000000..d33b257
--- /dev/null
+++ b/resources/js/kt_selectimage.js
@@ -0,0 +1,3 @@
+jQuery(document).ready(function() {
+ jQuery('#kt_image_select_container').selectImage();
+});
diff --git a/sql/mysql/install/structure.sql b/sql/mysql/install/structure.sql
index ff5db61..5883e56 100644
--- a/sql/mysql/install/structure.sql
+++ b/sql/mysql/install/structure.sql
@@ -633,8 +633,8 @@ CREATE TABLE `download_files` (
`session` varchar(100) NOT NULL,
`download_date` timestamp NULL default CURRENT_TIMESTAMP,
`downloaded` int(10) unsigned NOT NULL default '0',
- `filesize` int(10) unsigned NOT NULL,
- `content_version` int(10) unsigned NOT NULL,
+ `filesize` int(10) unsigned,
+ `content_version` int(10) unsigned,
`hash` varchar(100) NOT NULL,
PRIMARY KEY (`document_id`,`session`),
CONSTRAINT `download_files_ibfk_1` FOREIGN KEY (`document_id`) REFERENCES `documents` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
diff --git a/sql/mysql/upgrade/3.7.0.4/download_files.sql b/sql/mysql/upgrade/3.7.0.4/download_files.sql
new file mode 100644
index 0000000..ca50ef9
--- /dev/null
+++ b/sql/mysql/upgrade/3.7.0.4/download_files.sql
@@ -0,0 +1 @@
+ALTER TABLE download_files CHANGE COLUMN content_version content_version int(10) unsigned, CHANGE COLUMN filesize filesize int(10) unsigned;
\ No newline at end of file
diff --git a/templates/ktcore/forms/widgets/imageselect.smarty b/templates/ktcore/forms/widgets/imageselect.smarty
index c5b281a..7173055 100755
--- a/templates/ktcore/forms/widgets/imageselect.smarty
+++ b/templates/ktcore/forms/widgets/imageselect.smarty
@@ -2,32 +2,17 @@