diff --git a/config/dmsDefaults.php b/config/dmsDefaults.php index 0715aa3..5e79e0e 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',3); +define('LATEST_WEBSERVICE_VERSION',2); if (function_exists('apd_set_pprof_trace')) { diff --git a/ktwebservice/webservice.php b/ktwebservice/webservice.php index 3226c1f..8e8f3c9 100644 --- a/ktwebservice/webservice.php +++ b/ktwebservice/webservice.php @@ -97,7 +97,7 @@ define('KTWS_ERR_DB_PROBLEM', 99); if (!defined('LATEST_WEBSERVICE_VERSION')) { - define('LATEST_WEBSERVICE_VERSION', 3); + define('LATEST_WEBSERVICE_VERSION', 2); } function bool2str($bool) @@ -950,7 +950,7 @@ class KTWebService ); } - if($this->version >= 3) + if($this->version >= 2) { // add_document $this->__dispatch_map['add_document'] = @@ -2276,7 +2276,7 @@ class KTWebService */ function add_document($session_id, $folder_id, $title, $filename, $documenttype, $tempfilename, $unique_file_id = null) { - if(empty($tempfilename)){ + if(empty($tempfilename) && !empty($unique_file_id)){ $upload_manager = new KTUploadManager(); $tempfilename = $upload_manager->get_tempfile_from_unique_id($unique_file_id); @@ -3765,7 +3765,7 @@ class KTWebService */ function update_document_metadata($session_id,$document_id,$metadata, $sysdata=null) { - $this->debug("update_document_metadata('$session_id',$document_id,$metadata, $sysdata)"); + $this->debug("update_document_metadata('$session_id',$document_id," . print_r($metadata, true) . print_r($sysdata, true)); $kt = &$this->get_ktapi($session_id ); $responseType = 'kt_response'; diff --git a/lib/documentmanagement/documentutil.inc.php b/lib/documentmanagement/documentutil.inc.php index 667dce8..8e0ea2c 100755 --- a/lib/documentmanagement/documentutil.inc.php +++ b/lib/documentmanagement/documentutil.inc.php @@ -10,7 +10,7 @@ * KnowledgeTree Community Edition * Document Management Made Simple * Copyright (C) 2008, 2009 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 @@ -588,21 +588,21 @@ $sourceDocument->getName(), * - If still no valid date then takes the integers and separators to produce a best guess. */ function sanitizeDate($sDate) { - + //Checking for Normal Strings, e.g. 13 August 2009 etc. All formats accepted by strtotime() $datetime = date_create($sDate); $resDate = date_format($datetime, 'Y-m-d'); - + if (!trim($resDate) == '') { return $resDate; } else { //If null then removing quotes e.g. 14'th doesn't yield a valid date but 14th does $sDate = str_replace("'", '', $sDate); $sDate = str_replace('"', '', $sDate); - + $datetime = date_create($sDate); $resDate = date_format($datetime, 'Y-m-d'); - + if (!trim($resDate) == '') { return $resDate; } else { @@ -610,22 +610,22 @@ $sourceDocument->getName(), //Stripping non-numerics $sDate = preg_replace('/[^0-9]/', '-', $sDate); $token = strpos($sDate, '--'); - + while ($token != 0) { $sDate = str_replace('--', '-', $sDate); $token = strpos($sDate, '--'); } - + $datetime = date_create($sDate); $resDate = date_format($datetime, 'Y-m-d'); - + return $resDate; - + } } } - + // Forcefully sanitize metadata, specifically date values, to account for client tools that submit unvalidated date input // Will produce a best effort match to a valid date format. function sanitizeMetadata($oDocument, $aMetadata){ @@ -640,7 +640,7 @@ $sourceDocument->getName(), } $aSimpleMetadata[$oField->getId()] = $sValue; } - + foreach ($aFieldsets as $oFieldset) { $aFields =& $oFieldset->getFields(); $aFieldValues = array(); @@ -649,32 +649,34 @@ $sourceDocument->getName(), if (!empty($v)) { $aFieldValues[$oField->getId()] = $val; } - + //Sanitizing Date Values if ($oField->getDataType() == 'DATE') { $val = KTDocumentUtil::sanitizeDate($val); } - + if (!is_null($val)) { $MDPack[] = array( $oField, $val ); } - + } } - + return $MDPack; } - + // {{{ saveMetadata function saveMetadata(&$oDocument, $aMetadata, $aOptions = null) { $table = 'document_fields_link'; - + //Sanitizing Date Fields - $aMetadata = KTDocumentUtil::sanitizeMetadata($oDocument, $aMetadata); - + if(!empty($aMetadata)){ + $aMetadata = KTDocumentUtil::sanitizeMetadata($oDocument, $aMetadata); + } + $bNoValidate = KTUtil::arrayGet($aOptions, 'novalidate', false); if ($bNoValidate !== true) { @@ -1655,7 +1657,7 @@ $sourceDocument->getName(), DBUtil::commit(); } - + public static function getDocumentContent($oDocument) { global $default; @@ -1686,7 +1688,7 @@ $sourceDocument->getName(), } $content = file_get_contents($path); - + return $content; } }