Error!! - You have encountered a problem starting your document management system.
+
Please contact your systems administrator
+
For more details, click here
+
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/VERSION-NAME.txt b/docs/VERSION-NAME.txt
index c7b3c14..9a8c3c5 100644
--- a/docs/VERSION-NAME.txt
+++ b/docs/VERSION-NAME.txt
@@ -1 +1 @@
-OSS 3.5.2
+OSS 3.5.2 beta1
diff --git a/docs/VERSION-OSS.txt b/docs/VERSION-OSS.txt
index 87ce492..9b8155d 100644
--- a/docs/VERSION-OSS.txt
+++ b/docs/VERSION-OSS.txt
@@ -1 +1 @@
-3.5.2
+3.5.2 beta1
diff --git a/error_01.gif b/error_01.gif
new file mode 100644
index 0000000..3f7dfbf
--- /dev/null
+++ b/error_01.gif
diff --git a/errors.css b/errors.css
new file mode 100644
index 0000000..f5da2d6
--- /dev/null
+++ b/errors.css
@@ -0,0 +1,43 @@
+div#error-container {
+ width: 500px;
+ color: #555;
+ font-size: 11px;
+ font-family: Verdana, Arial, sans-serif;
+}
+div#error-container div {
+ height: 140px;
+}
+div#error-container h1 {
+ font-weight: lighter;
+ font-size: 22px;
+ margin-left: 100px;
+}
+div#error-container p {
+ margin-left: 100px;
+}
+
+ div#acc-error {
+ background: transparent url(error_01.gif) no-repeat top left;
+ }
+ div#acc-suspend {
+ background: transparent url(error_02.gif) no-repeat top left;
+ }
+ div#acc-maint {
+ background: transparent url(error_03.gif) no-repeat top left;
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ktapi/KTAPIDocument.inc.php b/ktapi/KTAPIDocument.inc.php
index 3ab4902..ec8cd3a 100644
--- a/ktapi/KTAPIDocument.inc.php
+++ b/ktapi/KTAPIDocument.inc.php
@@ -35,6 +35,8 @@
*
*/
+//require_once(KT_DIR . '/ktwebservice/KTUploadManager.inc.php');
+
class KTAPI_Document extends KTAPI_FolderItem
{
/**
@@ -175,14 +177,7 @@ class KTAPI_Document extends KTAPI_FolderItem
}
DBUtil::commit();
- $tempfilename=addslashes($tempfilename);
- $sql = "DELETE FROM uploaded_files WHERE tempfilename='$tempfilename'";
- $result = DBUtil::runQuery($sql);
- if (PEAR::isError($result))
- {
- return $result;
- }
-
+ KTUploadManager::temporary_file_imported($tempfilename);
}
/**
@@ -261,7 +256,7 @@ class KTAPI_Document extends KTAPI_FolderItem
return new KTAPI_Error(KTAPI_ERROR_INTERNAL_ERROR,$res);
}
- $oDocumentTransaction = & new DocumentTransaction($this->document, $reason, 'ktcore.transactions.force_checkin');
+ $oDocumentTransaction = new DocumentTransaction($this->document, $reason, 'ktcore.transactions.force_checkin');
$res = $oDocumentTransaction->create();
if (($res === false) || PEAR::isError($res)) {
@@ -280,13 +275,15 @@ class KTAPI_Document extends KTAPI_FolderItem
dcv.size,
w.name as workflow,
ws.name as workflow_state,
- dlt.name as link_type
+ dlt.name as link_type, dtl.name as document_type,
+ dcv.major_version, dcv.minor_version
FROM
document_link dl
INNER JOIN document_link_types dlt ON dl.link_type_id=dlt.id
INNER JOIN documents d ON dl.child_document_id=d.id
INNER JOIN document_metadata_version dmv ON d.metadata_version_id=dmv.id
INNER JOIN document_content_version dcv ON dmv.content_version_id=dcv.id
+ INNER JOIN document_types_lookup dtl ON dtl.id=dmv.document_type_id
LEFT OUTER JOIN workflow_documents wd ON d.id=wd.document_id
LEFT OUTER JOIN workflows w ON w.id=wd.workflow_id
LEFT OUTER JOIN workflow_states ws ON wd.state_id=ws.id
@@ -319,8 +316,12 @@ class KTAPI_Document extends KTAPI_FolderItem
$result[] = array(
'document_id'=>(int)$row['document_id'],
+ 'custom_document_no'=>'n/a',
+ 'oem_document_no'=>'n/a',
'title'=> $row['title'],
- 'size'=>(int)$row['size'],
+ 'document_type'=> $row['document_type'],
+ 'version'=> (float) ($row['major_version'] . '.' . $row['minor_version']),
+ 'filesize'=>(int)$row['size'],
'workflow'=>empty($row['workflow'])?'n/a':$row['workflow'],
'workflow_state'=>empty($row['workflow_state'])?'n/a':$row['workflow_state'],
'link_type'=>empty($row['link_type'])?'unknown':$row['link_type'],
@@ -432,7 +433,7 @@ class KTAPI_Document extends KTAPI_FolderItem
return new KTAPI_Error(KTAPI_ERROR_INTERNAL_ERROR,$res );
}
- $oDocumentTransaction = & new DocumentTransaction($this->document, $reason, 'ktcore.transactions.permissions_change');
+ $oDocumentTransaction = new DocumentTransaction($this->document, $reason, 'ktcore.transactions.permissions_change');
$res = $oDocumentTransaction->create();
if (($res === false) || PEAR::isError($res)) {
@@ -776,7 +777,7 @@ class KTAPI_Document extends KTAPI_FolderItem
return new KTAPI_Error(KTAPI_ERROR_INTERNAL_ERROR, $res);
}
- $oDocumentTransaction = & new DocumentTransaction($this->document, sprintf(_kt('Document archived: %s'), $reason), 'ktcore.transactions.update');
+ $oDocumentTransaction = new DocumentTransaction($this->document, sprintf(_kt('Document archived: %s'), $reason), 'ktcore.transactions.update');
$oDocumentTransaction->create();
DBUtil::commit();
@@ -1339,7 +1340,7 @@ class KTAPI_Document extends KTAPI_FolderItem
$workflowid=$this->document->getWorkflowId();
if (empty($workflowid))
{
- return new PEAR_Error(KTAPI_ERROR_WORKFLOW_NOT_IN_PROGRESS);
+ return array();
}
$result = array();
@@ -1402,126 +1403,169 @@ class KTAPI_Document extends KTAPI_FolderItem
// make sure we ge tthe latest
$this->clearCache();
+ $config = KTConfig::getSingleton();
+ $wsversion = $config->get('webservice/version', LATEST_WEBSERVICE_VERSION);
+
$detail = array();
$document = $this->document;
+ // get the document id
+ $detail['document_id'] = (int) $document->getId();
+
+ $detail['custom_document_no'] = 'n/a';
+ $detail['oem_document_no'] = 'n/a';
+
+ // get the title
$detail['title'] = $document->getName();
+ // get the document type
$documenttypeid=$document->getDocumentTypeID();
+ $documenttype = '* unknown *';
if (is_numeric($documenttypeid))
{
- $documenttype = DocumentType::get($documenttypeid);
+ $dt = DocumentType::get($documenttypeid);
- $documenttype=$documenttype->getName();
- }
- else
- {
- $documenttype = '* unknown *';
+ if (!is_null($dt) && !PEAR::isError($dt))
+ {
+ $documenttype=$dt->getName();
+ }
}
$detail['document_type'] = $documenttype;
- $detail['version'] = $document->getVersion();
+ // get the filename
$detail['filename'] = $document->getFilename();
- $detail['created_date'] = $document->getCreatedDateTime();
+ // get the filesize
+ $detail['filesize'] = (int) $document->getFileSize();
+
+ // get the folder id
+ $detail['folder_id'] = (int) $document->getFolderID();
+ // get the creator
$userid = $document->getCreatorID();
+ $username='n/a';
if (is_numeric($userid))
{
+ $username = '* unknown *';
$user = User::get($userid);
- $username=(is_null($user) || PEAR::isError($user))?'* unknown *':$user->getName();
- }
- else
- {
- $username='n/a';
+ if (!is_null($user) && !PEAR::isError($user))
+ {
+ $username = $user->getName();
+ }
}
$detail['created_by'] = $username;
- $detail['updated_date'] = $document->getLastModifiedDate();
- $detail['modified_date'] = $document->getLastModifiedDate();
- $userid = $document->getModifiedUserId();
+ // get the creation date
+ $detail['created_date'] = $document->getCreatedDateTime();
+
+ // get the checked out user
+ $userid = $document->getCheckedOutUserID();
+ $username='n/a';
if (is_numeric($userid))
{
+ $username = '* unknown *';
$user = User::get($userid);
- $username=(is_null($user) || PEAR::isError($user))?'* unknown *':$user->getName();
- }
- else
- {
- $username='n/a';
- }
- $detail['modified_by'] = $username;
- $detail['updated_by'] = $username;
- $detail['document_id'] = (int) $document->getId();
- $detail['folder_id'] = (int) $document->getFolderID();
-
- $workflowid = $document->getWorkflowId();
- if (is_numeric($workflowid))
- {
- $workflow = KTWorkflow::get($workflowid);
- $workflowname=(is_null($workflow) || PEAR::isError($workflow))?'* unknown *':$workflow->getName();
- }
- else
- {
- $workflowname='n/a';
+ if (!is_null($user) && !PEAR::isError($user))
+ {
+ $username = $user->getName();
+ }
}
- $detail['workflow'] = $workflowname;
+ $detail['checked_out_by'] = $username;
- $stateid = $document->getWorkflowStateId();
- if (is_numeric($stateid))
+ // get the checked out date
+ list($major, $minor, $fix) = explode('.', $default->systemVersion);
+ if ($major == 3 && $minor >= 5)
{
- $state = KTWorkflowState::get($stateid);
- $workflowstate=(is_null($state) || PEAR::isError($state))?'* unknown *':$state->getName();
+ $detail['checked_out_date'] = $document->getCheckedOutDate();
}
else
{
- $workflowstate = 'n/a';
+ $detail['checked_out_date'] = $detail['modified_date'];
}
- $detail['workflow_state']=$workflowstate;
-
- $userid = $document->getOwnerID();
+ if (is_null($detail['checked_out_date'])) $detail['checked_out_date'] = 'n/a';
+ // get the modified user
+ $userid = $document->getModifiedUserId();
+ $username='n/a';
if (is_numeric($userid))
{
+ $username = '* unknown *';
$user = User::get($userid);
- $username=(is_null($user) || PEAR::isError($user))?'* unknown *':$user->getName();
- }
- else
- {
- $username = 'n/a';
+ if (!is_null($user) && !PEAR::isError($user))
+ {
+ $username = $user->getName();
+ }
}
- $detail['owner'] = $username;
-
- $detail['is_immutable'] = (bool) $document->getImmutable();
-
+ $detail['modified_by'] = $detail['updated_by'] = $username;
- $userid = $document->getCheckedOutUserID();
+ // get the modified date
+ $detail['updated_date'] = $detail['modified_date'] = $document->getLastModifiedDate();
+ // get the owner
+ $userid = $document->getOwnerID();
+ $username='n/a';
if (is_numeric($userid))
{
+ $username = '* unknown *';
$user = User::get($userid);
- $username=(is_null($user) || PEAR::isError($user))?'* unknown *':$user->getName();
+ if (!is_null($user) && !PEAR::isError($user))
+ {
+ $username = $user->getName();
+ }
}
- else
+ $detail['owned_by'] = $username;
+
+ // get the version
+ $detail['version'] = $document->getVersion();
+ if ($wsversion >= 2)
{
- $username = 'n/a';
+ $detail['version'] = (float) $detail['version'];
}
- $detail['checked_out_by'] = $username;
- list($major, $minor, $fix) = explode('.', $default->systemVersion);
+ // check immutability
+ $detail['is_immutable'] = (bool) $document->getImmutable();
+ // check permissions
+ $detail['permissions'] = 'n/a';
- if ($major == 3 && $minor >= 5)
+ // get workflow name
+ $workflowid = $document->getWorkflowId();
+ $workflowname='n/a';
+ if (is_numeric($workflowid))
{
- $detail['checked_out_date'] = $document->getCheckedOutDate();
+ $workflow = KTWorkflow::get($workflowid);
+ if (!is_null($workflow) && !PEAR::isError($workflow))
+ {
+ $workflowname = $workflow->getName();
+ }
}
- else
+ $detail['workflow'] = $workflowname;
+
+ // get the workflow state
+ $stateid = $document->getWorkflowStateId();
+ $workflowstate = 'n/a';
+ if (is_numeric($stateid))
{
- $detail['checked_out_date'] = $detail['modified_date'];
+ $state = KTWorkflowState::get($stateid);
+ if (!is_null($state) && !PEAR::isError($state))
+ {
+ $workflowstate = $state->getName();
+ }
}
- if (is_null($detail['checked_out_date'])) $detail['checked_out_date'] = 'n/a';
+ $detail['workflow_state']=$workflowstate;
+ // get the full path
$detail['full_path'] = $this->ktapi_folder->get_full_path() . '/' . $this->get_title();
+ // get mime info
+ $mimetypeid = $document->getMimeTypeID();
+ $detail['mime_type'] =KTMime::getMimeTypeName($mimetypeid);
+ $detail['mime_icon_path'] =KTMime::getIconPath($mimetypeid);
+ $detail['mime_display'] =KTMime::getFriendlyNameForString($detail['mime_type']);
+
+ // get the storage path
+ $detail['storage_path'] = $document->getStoragePath();
+
return $detail;
}
@@ -1541,7 +1585,7 @@ class KTAPI_Document extends KTAPI_FolderItem
$options = array();
- $oDocumentTransaction = & new DocumentTransaction($this->document, 'Document downloaded', 'ktcore.transactions.download', $aOptions);
+ $oDocumentTransaction = new DocumentTransaction($this->document, 'Document downloaded', 'ktcore.transactions.download', $aOptions);
$oDocumentTransaction->create();
}
@@ -1564,6 +1608,13 @@ class KTAPI_Document extends KTAPI_FolderItem
return new KTAPI_Error(KTAPI_ERROR_INTERNAL_ERROR, $transactions );
}
+ $config = KTConfig::getSingleton();
+ $wsversion = $config->get('webservice/version', LATEST_WEBSERVICE_VERSION);
+ foreach($transactions as $key=>$transaction)
+ {
+ $transactions[$key]['version'] = (float) $transaction['version'];
+ }
+
return $transactions;
}
@@ -1576,6 +1627,9 @@ class KTAPI_Document extends KTAPI_FolderItem
{
$metadata_versions = KTDocumentMetadataVersion::getByDocument($this->document);
+ $config = KTConfig::getSingleton();
+ $wsversion = $config->get('webservice/version', LATEST_WEBSERVICE_VERSION);
+
$versions = array();
foreach ($metadata_versions as $version)
{
@@ -1585,18 +1639,20 @@ class KTAPI_Document extends KTAPI_FolderItem
$userid = $document->getModifiedUserId();
$user = User::get($userid);
- if (PEAR::isError($user))
- {
- $username = $user->getName();
- }
- else
+ $username = 'Unknown';
+ if (!PEAR::isError($user))
{
- $username = 'Unknown';
+ $username = is_null($user)?'n/a':$user->getName();
}
$version['user'] = $username;
$version['metadata_version'] = $document->getMetadataVersion();
$version['content_version'] = $document->getVersion();
+ if ($wsversion >= 2)
+ {
+ $version['metadata_version'] = (int) $version['metadata_version'];
+ $version['content_version'] = (float) $version['content_version'];
+ }
$versions[] = $version;
}
@@ -1616,7 +1672,7 @@ class KTAPI_Document extends KTAPI_FolderItem
}
DBUtil::startTransaction();
- $transaction = & new DocumentTransaction($this->document, "Document expunged", 'ktcore.transactions.expunge');
+ $transaction = new DocumentTransaction($this->document, "Document expunged", 'ktcore.transactions.expunge');
$transaction->create();
diff --git a/ktapi/KTAPIFolder.inc.php b/ktapi/KTAPIFolder.inc.php
index 5962c79..100667b 100644
--- a/ktapi/KTAPIFolder.inc.php
+++ b/ktapi/KTAPIFolder.inc.php
@@ -35,6 +35,8 @@
*
*/
+require_once(KT_DIR . '/ktwebservice/KTUploadManager.inc.php');
+
class KTAPI_Folder extends KTAPI_FolderItem
{
/**
@@ -197,6 +199,7 @@ class KTAPI_Folder extends KTAPI_FolderItem
function get_full_path()
{
$path = $this->folder->getFullPath() . '/' . $this->folder->getName();
+ if (substr($path,0,1) == '/') $path = substr($path,1);
return $path;
}
@@ -350,7 +353,11 @@ class KTAPI_Folder extends KTAPI_FolderItem
'id' => (int) $folder->getId(),
'item_type' => 'F',
+ 'custom_document_no'=>'n/a',
+ 'oem_document_no'=>'n/a',
+
'title' => $folder->getName(),
+ 'document_type' => 'n/a',
'filename' => $folder->getName(),
'filesize' => 'n/a',
@@ -367,7 +374,7 @@ class KTAPI_Folder extends KTAPI_FolderItem
'version' => 'n/a',
- 'immutable'=> 'n/a',
+ 'is_immutable'=> 'n/a',
'permissions' => 'n/a',
'workflow'=>'n/a',
@@ -469,11 +476,19 @@ class KTAPI_Folder extends KTAPI_FolderItem
if ($wsversion >= 2)
{
+ $docTypeId = $document->getDocumentTypeID();
+ $documentType = DocumentType::get($docTypeId);
+
+
$contents[] = array(
'id' => (int) $document->getId(),
'item_type' => 'D',
+ 'custom_document_no'=>'n/a',
+ 'oem_document_no'=>'n/a',
+
'title' => $document->getName(),
+ 'document_type'=>$documentType->getName(),
'filename' => $document->getFileName(),
'filesize' => $document->getFileSize(),
@@ -490,7 +505,7 @@ class KTAPI_Folder extends KTAPI_FolderItem
'version' => $document->getMajorVersionNumber() . '.' . $document->getMinorVersionNumber(),
- 'immutable'=> $document->getImmutable()?'true':'false',
+ 'is_immutable'=> $document->getImmutable()?'true':'false',
'permissions' => 'n/a',
'workflow'=> $workflow,
@@ -590,13 +605,7 @@ class KTAPI_Folder extends KTAPI_FolderItem
}
DBUtil::commit();
- $tempfilename=addslashes($tempfilename);
- $sql = "DELETE FROM uploaded_files WHERE tempfilename='$tempfilename'";
- $result = DBUtil::runQuery($sql);
- if (PEAR::isError($result))
- {
- return $result;
- }
+ KTUploadManager::temporary_file_imported($tempfilename);
return new KTAPI_Document($this->ktapi, $this, $document);
}
diff --git a/ktapi/KTAPISession.inc.php b/ktapi/KTAPISession.inc.php
index 4fafb88..64e96e3 100644
--- a/ktapi/KTAPISession.inc.php
+++ b/ktapi/KTAPISession.inc.php
@@ -54,7 +54,7 @@ class KTAPI_Session
$this->ktapi=&$ktapi;
$this->user=&$user;
- $this->origUserId = $_SESSION['userID'];
+ $this->origUserId = isset($_SESSION['userID'])?$_SESSION['userID']:null;
$_SESSION['userID']=$user->getId();
$this->active = false;
}
diff --git a/ktwebdav/lib/KTWebDAVServer.inc.php b/ktwebdav/lib/KTWebDAVServer.inc.php
index 500ad7a..b804e07 100644
--- a/ktwebdav/lib/KTWebDAVServer.inc.php
+++ b/ktwebdav/lib/KTWebDAVServer.inc.php
@@ -42,7 +42,7 @@ require_once 'Log.php'; // thirdparty PEAR
$userAgentValue = $_SERVER['HTTP_USER_AGENT'];
if (stristr($userAgentValue, "Microsoft Data Access Internet Publishing Provider DAV")) {
- // Fix for Novell Netdrive
+ // Fix for Novell Netdrive
chdir(realpath(dirname(__FILE__)));
require_once '../../config/dmsDefaults.php'; // This is our plug into KT.
}else{
@@ -1217,7 +1217,7 @@ class KTWebDAVServer extends HTTP_WebDAV_Server
$sQuery .= "ON D.metadata_version_id = DM.id ";
$sQuery .= "LEFT JOIN document_content_version AS DC ";
$sQuery .= "ON DM.content_version_id = DC.id ";
- $sQuery .= "WHERE D.folder_id = ? AND DC.filename = ?";
+ $sQuery .= "WHERE D.folder_id = ? AND DC.filename = ? AND D.status_id=1";
$aParams = array($iFolderID, $sFileName);
$iDocumentID = DBUtil::getOneResultKey(array($sQuery, $aParams), 'id');
diff --git a/ktwebservice/KTDownloadManager.inc.php b/ktwebservice/KTDownloadManager.inc.php
index 16bbfb3..667a63c 100644
--- a/ktwebservice/KTDownloadManager.inc.php
+++ b/ktwebservice/KTDownloadManager.inc.php
@@ -2,39 +2,39 @@
/**
*
- * $Id:$
+ * $Id$
*
* KTDownloadManager manages files in the download_files table.
*
* KnowledgeTree Open Source Edition
* Document Management Made Simple
* Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited
- *
+ *
* 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 The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
* Blake Street, Observatory, 7925 South Africa. 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
- * copyright notice.
+ * must display the words "Powered by KnowledgeTree" and retain the original
+ * copyright notice.
* Contributor( s): ______________________________________
*
*/
@@ -57,7 +57,10 @@ class KTDownloadManager
$config = &KTConfig::getSingleton();
$this->age = $config->get('webservice/downloadExpiry',5);
- $this->download_url = $config->get('webservice/downloadUrl');
+
+ $protocol = $config->get('KnowledgeTree/sslEnabled')?'https':'http';
+
+ $this->download_url = $protocol . '://' . $_SERVER['HTTP_HOST'] . $config->get('webservice/downloadUrl');
$this->random=$config->get('webservice/randomKeyText','jhsdf8q1jkjpoiudfs7sd3ds1');
}
diff --git a/ktwebservice/KTUploadManager.inc.php b/ktwebservice/KTUploadManager.inc.php
index 2aff2ff..32dd4fd 100644
--- a/ktwebservice/KTUploadManager.inc.php
+++ b/ktwebservice/KTUploadManager.inc.php
@@ -52,7 +52,8 @@ class KTUploadManager
$config = KTConfig::getSingleton();
$this->age = $config->get('webservice/uploadExpiry',60);
- $this->temp_dir= $config->get('webservice/uploadDirectory');
+ $this->temp_dir = $config->get('webservice/uploadDirectory');
+ $this->temp_dir = str_replace('\\','/', $this->temp_dir);
}
/**
@@ -63,10 +64,48 @@ class KTUploadManager
function set_session($session)
{
$user = &$session->get_user();
- $this->userid=$user->getId();
+ $this->userid=$_SESSION['userID'];
$this->session = $session->get_session();
}
+ function get_temp_filename($prefix)
+ {
+ $tempfilename = tempnam($this->temp_dir,$prefix);
+
+ return $tempfilename;
+ }
+
+ function is_valid_temporary_file($tempfilename)
+ {
+ $tempdir = substr($tempfilename,0,strlen($this->temp_dir));
+ $tempdir = str_replace('\\','/', $tempdir);
+ return ($tempdir == $this->temp_dir);
+ }
+
+ function store_base64_file($base64, $prefix= 'sa_')
+ {
+ $tempfilename = $this->get_temp_filename($prefix);
+ if (!is_writable($tempfilename))
+ {
+ return new PEAR_Error("Cannot write to file: $tempfilename");
+ }
+
+ if (!$this->is_valid_temporary_file($tempfilename))
+ {
+ return new PEAR_Error("Invalid temporary file: $tempfilename. There is a problem with the temporary storage path: $this->temp_dir.");
+ }
+
+ $fp=fopen($tempfilename, 'wb');
+ if ($fp === false)
+ {
+ return new PEAR_Error("Cannot write content to temporary file: $tempfilename.");
+ }
+ fwrite($fp, base64_decode($base64));
+ fclose($fp);
+
+ return $tempfilename;
+ }
+
/**
* This tells the manager to manage a file that has been uploaded.
*
@@ -80,8 +119,9 @@ class KTUploadManager
$now=date('Y-m-d H:i:s');
$now_str=date('YmdHis');
- $newtempfile = realpath($this->temp_dir) . '/' . $this->userid . '-'. $now_str;
- if (DIRECTORY_SEPARATOR == '\\') {
+ $newtempfile = realpath($this->temp_dir) . '/' . $_SESSION['userID'] . '-'. $now_str;
+ if (OS_WINDOWS)
+ {
$tempfile = str_replace('/','\\',$tempfile);
$newtempfile = str_replace('\\','/',$newtempfile);
}
@@ -105,12 +145,19 @@ class KTUploadManager
return $id;
}
global $php_errormsg;
- $result = @move_uploaded_file($tempfile, $newtempfile);
+ if (is_uploaded_file($tempfile))
+ {
+ $result = @move_uploaded_file($tempfile, $newtempfile);
+ }
+ else
+ {
+ $result = @rename($tempfile, $newtempfile);
+ }
+
$tmp = $php_errormsg;
if ($result == false)
{
-
DBUtil::rollback();
return new PEAR_Error($tmp);
}
@@ -136,11 +183,10 @@ class KTUploadManager
return $result;
}
- function imported_file($action, $filename, $documentid)
+ function temporary_file_imported($tempfilename)
{
- DBUtil::startTransaction();
- $filename=basename($filename);
- $sql = "DELETE FROM uploaded_files WHERE action='$action' AND filename='$filename'";
+ $tempfilename = addslashes(str_replace('\\','/',$tempfilename));
+ $sql = "DELETE FROM uploaded_files WHERE tempfilename='$tempfilename'";
$rs = DBUtil::runQuery($sql);
if (PEAR::isError($rs))
{
@@ -148,15 +194,7 @@ class KTUploadManager
return false;
}
- $sql = "INSERT INTO index_files(document_id, user_id) VALUES($documentid, $this->userid)";
- DBUtil::runQuery($sql);
- if (PEAR::isError($rs))
- {
- DBUtil::rollback();
- return false;
- }
- DBUtil::commit();
return true;
}
diff --git a/ktwebservice/nunit/README b/ktwebservice/nunit/README
index 909f4ba..97aab3c 100644
--- a/ktwebservice/nunit/README
+++ b/ktwebservice/nunit/README
@@ -11,6 +11,30 @@ The unit tests were written for NUnit. NUnit 2.2.0 was used during development.
This framework was developed in Linux using Mono.
+DATABASE
+--------
+
+Review helper.cs to see the configuration settings. UnixODBC is used. Sample config files:
+
+ # odbc.ini
+
+[ktdms]
+Driver = myodbcdriver
+Description = MySQL ODBC 2.50 Driver DSN
+SERVER = localhost
+PORT =
+Socket = /tmp/mysql.sock
+USER = root
+Password =
+Database = ktdms
+OPTION = 3
+
+ # odbcinst.ini
+[myodbcdriver]
+Description = MySQL ODBC 2.50 Driver DSN
+Driver = /usr/lib64/unixODBC/libmyodbc3.so
+
+
The document type 'NewType' must be added to the database for the document_type.cs unit test to run.
@@ -37,3 +61,4 @@ For more information:
http://nunit.org/
http://www.mono-project.com/
+http://www.unixodbc.org
diff --git a/ktwebservice/nunit/document_add.cs b/ktwebservice/nunit/document_add.cs
index 418da26..2cb58e0 100644
--- a/ktwebservice/nunit/document_add.cs
+++ b/ktwebservice/nunit/document_add.cs
@@ -8,20 +8,20 @@ namespace MonoTests.KnowledgeTree
public class AddDocumentTest : KTTest
{
-
+
private int _docId;
private int _folderId;
private String _filename;
- private String _content;
+ private String _content;
public AddDocumentTest() : base()
- {
+ {
this._folderId = 1;
- }
+ }
[SetUp]
public void SetUp()
- {
+ {
this._filename = Helper.isUnix()?"/tmp/kt_unit_test1.txt":"c:\\kt_unit_test1.txt";
this._content = "hello world!";
@@ -29,10 +29,10 @@ namespace MonoTests.KnowledgeTree
[TearDown]
public void TearDown()
- {
- Helper.deleteFile(this._filename);
- }
-
+ {
+ Helper.deleteFile(this._filename);
+ }
+
[Test]
public void FindDocumentBeforeAdd()
{
@@ -49,7 +49,7 @@ namespace MonoTests.KnowledgeTree
{
System.Console.WriteLine("document not found. that is ok!");
}
- }
+ }
[Test]
public void FindFolderBeforeAdd()
@@ -67,7 +67,7 @@ namespace MonoTests.KnowledgeTree
{
if (this._verbose) System.Console.WriteLine("folder not found. that is ok!");
}
- }
+ }
[Test]
public void AddDocument()
@@ -89,7 +89,7 @@ namespace MonoTests.KnowledgeTree
Assert.AreEqual(0, response1.status_code);
Assert.AreEqual("kt unit test1", response1.title);
Assert.AreEqual("Default", response1.document_type);
- Assert.AreEqual("0.1", response1.version);
+ Assert.AreEqual(0.1, response1.version);
Assert.AreEqual("kt_unit_test1.txt", response1.filename);
Assert.IsFalse(response1.created_date == null);
@@ -172,7 +172,7 @@ namespace MonoTests.KnowledgeTree
Assert.AreEqual(0, response1.status_code);
Assert.AreEqual(filename, response1.title);
Assert.AreEqual("Default", response1.document_type);
- Assert.AreEqual("0.1", response1.version);
+ Assert.AreEqual(0.1, response1.version);
Assert.AreEqual("kt_unit_test1.txt", response1.filename);
Assert.IsFalse(response1.created_date == null);
diff --git a/ktwebservice/nunit/document_contents.cs b/ktwebservice/nunit/document_contents.cs
new file mode 100644
index 0000000..767355d
--- /dev/null
+++ b/ktwebservice/nunit/document_contents.cs
@@ -0,0 +1,91 @@
+using NUnit.Framework;
+using System;
+using System.IO;
+
+namespace MonoTests.KnowledgeTree
+{
+ [TestFixture]
+ public class DocumentContentsTest : KTTest
+ {
+ private int _folderId;
+ private Document _doc1;
+
+
+ [SetUp]
+ public void SetUp()
+ {
+
+ this._doc1 = new Document(1, this._session, this._kt, this._verbose,false);
+ this._doc1.createFile(1);
+
+ kt_folder_detail response = this._kt.create_folder(this._session, 1, "kt_unit_testabc");
+
+
+ this._folderId = response.id;
+
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ this._doc1.deleteFile();
+ }
+
+ [Test]
+ public void Query()
+ {
+
+ kt_folder_contents response = this._kt.get_folder_contents(this._session, 1, 1, "DF");
+
+ Assert.AreEqual(0, response.status_code);
+ Assert.AreEqual(2, response.items.Length);
+
+ Assert.AreEqual(this._doc1.docId, response.items[1].id);
+
+ Assert.AreEqual("n/a", response.items[1].custom_document_no);
+ Assert.AreEqual("n/a", response.items[1].oem_document_no);
+
+ Assert.AreEqual("D", response.items[1].item_type);
+ Assert.AreEqual(this._doc1.title, response.items[1].title);
+ Assert.AreEqual(this._doc1.realFilename, response.items[1].filename);
+ Assert.AreEqual("Default", response.items[1].document_type);
+ Assert.AreEqual(this._doc1.filesize+1 + "", response.items[1].filesize);
+
+ Assert.AreEqual("Administrator", response.items[1].created_by);
+ Assert.AreEqual("Administrator", response.items[1].modified_by);
+ Assert.AreEqual("n/a", response.items[1].checked_out_by);
+ Assert.AreEqual("Administrator", response.items[1].owned_by);
+ Assert.AreEqual("0.1", response.items[1].version);
+ Assert.AreEqual("false", response.items[1].is_immutable);
+ Assert.AreEqual("n/a", response.items[1].permissions);
+ Assert.AreEqual("n/a", response.items[1].workflow);
+ Assert.AreEqual("n/a", response.items[1].workflow_state);
+ Assert.AreEqual("text/plain", response.items[1].mime_type);
+ Assert.AreEqual("text", response.items[1].mime_icon_path);
+ Assert.AreEqual("Plain Text", response.items[1].mime_display);
+ Assert.IsTrue("" != response.items[1].storage_path);
+
+ Assert.AreEqual(this._folderId, response.items[0].id);
+ Assert.AreEqual("F", response.items[0].item_type);
+ Assert.AreEqual("kt_unit_testabc", response.items[0].title);
+
+ Assert.AreEqual("kt_unit_testabc", response.items[0].filename);
+ Assert.AreEqual("n/a", response.items[0].document_type);
+ Assert.AreEqual("n/a", response.items[0].filesize);
+
+ Assert.AreEqual("Administrator", response.items[0].created_by);
+ Assert.AreEqual("n/a", response.items[0].modified_by);
+ Assert.AreEqual("n/a", response.items[0].checked_out_by);
+ Assert.AreEqual("n/a", response.items[0].owned_by);
+ Assert.AreEqual("n/a", response.items[0].version);
+ Assert.AreEqual("n/a", response.items[0].is_immutable);
+ Assert.AreEqual("n/a", response.items[0].permissions);
+ Assert.AreEqual("n/a", response.items[0].workflow);
+ Assert.AreEqual("n/a", response.items[0].workflow_state);
+ Assert.AreEqual("folder", response.items[0].mime_type);
+ Assert.AreEqual("folder", response.items[0].mime_icon_path);
+ Assert.AreEqual("Folder", response.items[0].mime_display);
+ Assert.AreEqual("n/a",response.items[0].storage_path);
+ }
+ }
+}
diff --git a/ktwebservice/nunit/document_detail.cs b/ktwebservice/nunit/document_detail.cs
index 85619d7..3ab6eb3 100644
--- a/ktwebservice/nunit/document_detail.cs
+++ b/ktwebservice/nunit/document_detail.cs
@@ -6,16 +6,16 @@ namespace MonoTests.KnowledgeTree
{
[TestFixture]
public class DocumentDetailTest : KTTest
- {
+ {
private int _docId;
private int _folderId;
private String _filename;
- private String _content;
+ private String _content;
[SetUp]
public void SetUp()
- {
+ {
this._filename = Helper.isUnix()?"/tmp/kt_unit_test1.txt":"c:\\kt_unit_test1.txt";
@@ -23,7 +23,7 @@ namespace MonoTests.KnowledgeTree
this._content = "hello world!";
- Helper.writeFile(this._filename, this._content);
+ Helper.writeFile(this._filename, this._content);
this._folderId = 1;
kt_document_detail response1 = this._kt.add_base64_document(this._session, this._folderId, filename, this._filename, "Default", Helper.ConvertFileToBase64Encoding(this._filename));
@@ -47,7 +47,7 @@ namespace MonoTests.KnowledgeTree
if (this._verbose && response.status_code != 0)
{
System.Console.WriteLine("Could not delete file: " + this._filename);
- }
+ }
}
@@ -61,12 +61,54 @@ namespace MonoTests.KnowledgeTree
[Test]
public void DocumentExistanceTest()
{
- kt_document_detail response = this._kt.get_document_detail(this._session, this._docId,"");
+ kt_document_detail response = this._kt.get_document_detail(this._session, this._docId,"MLTVH");
Assert.AreEqual(0, response.status_code);
Assert.AreEqual(this._docId, response.document_id);
+ Assert.AreEqual("kt unit test1", response.title);
+ Assert.AreEqual("n/a", response.custom_document_no);
+ Assert.AreEqual("n/a", response.oem_document_no);
+ Assert.AreEqual("Default", response.document_type);
+ Assert.AreEqual("Root Folder/kt unit test1", response.full_path);
+ Assert.AreEqual("kt_unit_test1.txt", response.filename);
+ Assert.AreEqual(this._content.Length + 1, response.filesize);
+ Assert.AreEqual(this._folderId, response.folder_id);
+ Assert.AreEqual("Administrator", response.created_by);
+ Assert.IsTrue("" != response.created_date);
+ Assert.AreEqual("n/a", response.checked_out_by);
+ Assert.IsTrue("" != response.checked_out_date);
+ Assert.AreEqual("Administrator", response.modified_by);
+ Assert.IsTrue("" != response.modified_date);
+ Assert.AreEqual("Administrator", response.owned_by);
+ Assert.AreEqual(0.1, response.version);
+ Assert.AreEqual(false, response.is_immutable);
+ Assert.AreEqual("n/a", response.permissions);
+ Assert.AreEqual("n/a", response.workflow);
+ Assert.AreEqual("n/a", response.workflow_state);
+ Assert.AreEqual("text/plain", response.mime_type);
+ Assert.AreEqual("text", response.mime_icon_path);
+ Assert.AreEqual("Plain Text", response.mime_display);
+ Assert.IsTrue("" != response.storage_path);
+ Assert.AreEqual(2, response.metadata.Length);
+ Assert.AreEqual(null, response.links);
+
+ Assert.AreEqual(1, response.transaction_history.Length);
+ Assert.AreEqual("Create", response.transaction_history[0].transaction_name);
+ Assert.AreEqual("Administrator", response.transaction_history[0].username);
+ Assert.AreEqual(0.1, response.transaction_history[0].version);
+ Assert.AreEqual("Document created", response.transaction_history[0].comment);
+ Assert.IsTrue("" != response.transaction_history[0].datetime);
+
+ Assert.AreEqual(1, response.version_history.Length);
+ Assert.AreEqual("Administrator", response.version_history[0].user);
+ Assert.AreEqual(0, response.version_history[0].metadata_version);
+ Assert.AreEqual(0.1, response.version_history[0].content_version);
+
+
+
+ Assert.AreEqual(null, response.transitions);
}
- [Test]
+ //[Test]
public void GetDetailByTitleTest()
{
kt_document_detail response = this._kt.get_document_detail_by_name(this._session, 1, "Root Folder/kt unit test1", "T","");
@@ -76,7 +118,7 @@ namespace MonoTests.KnowledgeTree
}
- [Test]
+ //[Test]
public void GetDetailByTitle2Test()
{
kt_document_detail response = this._kt.get_document_detail_by_title(this._session, 1, "Root Folder/kt unit test1", "");
@@ -85,7 +127,7 @@ namespace MonoTests.KnowledgeTree
Assert.AreEqual(this._docId, response.document_id);
}
- [Test]
+ //[Test]
public void GetDetailByFileTest()
{
kt_document_detail response = this._kt.get_document_detail_by_name(this._session, 1, "Root Folder/kt_unit_test1.txt", "F","");
@@ -93,7 +135,7 @@ namespace MonoTests.KnowledgeTree
Assert.AreEqual(0, response.status_code);
Assert.AreEqual(this._docId, response.document_id);
}
- [Test]
+ //[Test]
public void GetDetailByFile2Test()
{
kt_document_detail response = this._kt.get_document_detail_by_filename(this._session, 1, "Root Folder/kt_unit_test1.txt", "");
@@ -102,7 +144,7 @@ namespace MonoTests.KnowledgeTree
Assert.AreEqual(this._docId, response.document_id);
}
- [Test]
+ //[Test]
public void GetDetailByUnknownNameTest()
{
kt_document_detail response = this._kt.get_document_detail_by_name(this._session, 1, "Root Folder/kt_unit_test1.ssssdasdasd", "F","");
diff --git a/ktwebservice/nunit/document_download.cs b/ktwebservice/nunit/document_download.cs
index 6112020..68924e7 100644
--- a/ktwebservice/nunit/document_download.cs
+++ b/ktwebservice/nunit/document_download.cs
@@ -1,12 +1,10 @@
using NUnit.Framework;
using System;
using System.IO;
-using System.Net;
+using System.Net;
namespace MonoTests.KnowledgeTree
-{
-
-
+{
[TestFixture]
public class DocumentSystemMetadataTest : KTTest
{
@@ -61,10 +59,11 @@ namespace MonoTests.KnowledgeTree
long length = Helper.ConvertBase64EncodingToFile(update_resp.message, filename);
- //System.Console.WriteLine(Helper.readFile(filename));
+ System.Console.WriteLine(Helper.readFile(filename));
// TODO - why???
- //Assert.AreEqual(length, this._doc1.filesize);
+ Assert.AreEqual(length, this._doc1.filesize+1);
+
}
}
}
diff --git a/ktwebservice/nunit/document_links.cs b/ktwebservice/nunit/document_links.cs
index f7dc767..999d34f 100644
--- a/ktwebservice/nunit/document_links.cs
+++ b/ktwebservice/nunit/document_links.cs
@@ -47,6 +47,15 @@ namespace MonoTests.KnowledgeTree
Assert.AreEqual(this._doc1.docId, linkresp.parent_document_id);
Assert.AreEqual(1, linkresp.links.Length);
Assert.AreEqual(this._doc2.docId, linkresp.links[0].document_id);
+ Assert.AreEqual(this._doc2.title, linkresp.links[0].title);
+ Assert.AreEqual("Default", linkresp.links[0].document_type);
+ Assert.AreEqual(this._doc2.filesize+1, linkresp.links[0].filesize);
+ Assert.AreEqual(0.1, linkresp.links[0].version);
+ Assert.AreEqual("n/a", linkresp.links[0].workflow);
+ Assert.AreEqual("n/a", linkresp.links[0].workflow_state);
+ Assert.AreEqual("Reference", linkresp.links[0].link_type);
+ Assert.AreEqual("n/a", linkresp.links[0].custom_document_no);
+ Assert.AreEqual("n/a", linkresp.links[0].oem_document_no);
response = this._kt.unlink_documents(this._session, this._doc1.docId, this._doc2.docId);
Assert.AreEqual(0, response.status_code);
diff --git a/ktwebservice/nunit/document_metadata.cs b/ktwebservice/nunit/document_metadata.cs
index 3d8a1a2..af29019 100644
--- a/ktwebservice/nunit/document_metadata.cs
+++ b/ktwebservice/nunit/document_metadata.cs
@@ -108,5 +108,42 @@ namespace MonoTests.KnowledgeTree
}
+ [Test]
+ public void UpdateDocumentMetadataWithSpecialCharactersTest()
+ {
+ kt_metadata_fieldset[] fs = new kt_metadata_fieldset[1];
+ fs[0] = new kt_metadata_fieldset();
+ fs[0].fieldset = "General information";
+ fs[0].fields = new kt_metadata_field[3];
+ fs[0].fields[0] = new kt_metadata_field();
+ fs[0].fields[0].name = "Document Author";
+ fs[0].fields[0].value = "Joe \\Soap";
+ fs[0].fields[1] = new kt_metadata_field();
+ fs[0].fields[1].name = "Category";
+ fs[0].fields[1].value = "Tec/hn\\ical/";
+ fs[0].fields[2] = new kt_metadata_field();
+ fs[0].fields[2].name = "Media Type";
+ fs[0].fields[2].value = "Text'";
+
+ kt_sysdata_item[] sysdata = new kt_sysdata_item[0];
+
+ kt_document_detail update_resp = this._kt.update_document_metadata(this._session, this._docId, fs, sysdata);
+ Assert.AreEqual(0, update_resp.status_code);
+ Assert.AreEqual("General information", update_resp.metadata[1].fieldset);
+
+ Assert.AreEqual("Document Author", update_resp.metadata[1].fields[0].name);
+ Assert.AreEqual("Joe \\Soap", update_resp.metadata[1].fields[0].value);
+
+ Assert.AreEqual("Category", update_resp.metadata[1].fields[1].name);
+ Assert.AreEqual("Tec/hn\\ical/", update_resp.metadata[1].fields[1].value);
+
+ Assert.AreEqual("Media Type", update_resp.metadata[1].fields[2].name);
+ Assert.AreEqual("Text'", update_resp.metadata[1].fields[2].value);
+
+
+ }
+
+
+
}
}
diff --git a/ktwebservice/nunit/folder.cs b/ktwebservice/nunit/folder.cs
index 2cfdb74..7279ebb 100644
--- a/ktwebservice/nunit/folder.cs
+++ b/ktwebservice/nunit/folder.cs
@@ -7,7 +7,7 @@ namespace MonoTests.KnowledgeTree
[TestFixture]
public class FolderTest : KTTest
{
-
+
private int _folder_id;
private int _subfolder_id;
@@ -18,7 +18,7 @@ namespace MonoTests.KnowledgeTree
[TearDown]
public void TearDown()
- {
+ {
}
[Test]
@@ -30,7 +30,7 @@ namespace MonoTests.KnowledgeTree
Assert.AreEqual(1, response.id);
Assert.AreEqual("Root Folder", response.folder_name);
Assert.AreEqual(0, response.parent_id);
- Assert.AreEqual("/Root Folder", response.full_path); // ??? DOESNT SEEM CONSISTENT - should be 'Root Filder'
+ Assert.AreEqual("Root Folder", response.full_path);
}
[Test]
@@ -74,8 +74,7 @@ namespace MonoTests.KnowledgeTree
[Test]
public void GetFolderContents()
{
-
- kt_folder_contents response = this._kt.get_folder_contents(this._session, this._folder_id, 1, "DF");
+ kt_folder_contents response = this._kt.get_folder_contents(this._session, this._folder_id, 1, "DF");
Assert.AreEqual(0,response.status_code);
Assert.AreEqual(this._folder_id,response.folder_id);
Assert.AreEqual("kt_unit_test", response.folder_name);
@@ -86,30 +85,43 @@ namespace MonoTests.KnowledgeTree
Assert.AreEqual(this._subfolder_id, response2.folder_id);
Assert.AreEqual("subfolder", response2.folder_name);
Assert.AreEqual("Root Folder/kt_unit_test/subfolder", response2.full_path);
- }
+ }
[Test]
public void RenameFolder()
{
-
- kt_response response = this._kt.rename_folder(this._session, this._subfolder_id, "subfolder2");
+ kt_response response = this._kt.rename_folder(this._session, this._subfolder_id, "subfolde'r2");
Assert.AreEqual(0, response.status_code);
kt_folder_detail response2 = this._kt.get_folder_detail(this._session, this._subfolder_id);
Assert.AreEqual(0, response2.status_code);
Assert.AreEqual(this._subfolder_id, response2.id);
- Assert.AreEqual("subfolder2", response2.folder_name);
+ Assert.AreEqual("subfolde'r2", response2.folder_name);
Assert.AreEqual(this._folder_id, response2.parent_id);
- Assert.AreEqual("Root Folder/kt_unit_test/subfolder2", response2.full_path);
- }
+ Assert.AreEqual("Root Folder/kt_unit_test/subfolde'r2", response2.full_path);
+ }
[Test]
public void RemoveFolder()
{
-
- kt_response response = this._kt.delete_folder(this._session, this._folder_id, "unit testing remove");
+ kt_response response = this._kt.delete_folder(this._session, this._folder_id, "unit testing remove");
Assert.AreEqual(0, response.status_code);
- }
+ }
+ [Test]
+ public void AddFolderWithSpecialCharacters()
+ {
+ kt_folder_detail response = this._kt.create_folder(this._session, 1, "kt.unit.test");
+ Assert.AreEqual(0,response.status_code);
+ Assert.AreEqual("kt.unit.test",response.folder_name);
+
+ response = this._kt.create_folder(this._session, 1, "kt ' unit \" test");
+ Assert.AreEqual(0,response.status_code);
+ Assert.AreEqual("kt ' unit \" test",response.folder_name);
+
+ response = this._kt.create_folder(this._session, 1, "kt - unit - test");
+ Assert.AreEqual(0,response.status_code);
+ Assert.AreEqual("kt - unit - test",response.folder_name);
+ }
}
}
diff --git a/ktwebservice/nunit/helper.cs b/ktwebservice/nunit/helper.cs
index da4ef72..35a3886 100644
--- a/ktwebservice/nunit/helper.cs
+++ b/ktwebservice/nunit/helper.cs
@@ -3,6 +3,8 @@ using System.Text;
using System.Net;
using System.IO;
using System.Collections;
+using System.Data;
+using System.Data.Odbc;
namespace MonoTests.KnowledgeTree
{
@@ -22,17 +24,56 @@ namespace MonoTests.KnowledgeTree
{
protected KTWebService _kt;
protected String _session;
- protected bool _verbose;
+ protected bool _verbose;
+
public KTTest()
{
this._kt = new KTWebService();
kt_response response = this._kt.login("admin","admin","127.0.0.1");
this._session = response.message;
- this._verbose = false;
-
+ this._verbose = false;
+ this.setupDb();
}
+ void setupDb()
+ {
+
+ String connectionString = "DSN=ktdms;" + "UID=root;" + "PWD=";
+ try
+ {
+ IDbConnection dbcon = new OdbcConnection(connectionString);
+ if (dbcon == null)
+ {
+ System.Console.WriteLine("Cannot create connection");
+ }
+ dbcon.Open();
+ IDbCommand dbcmd = dbcon.CreateCommand();
+ if (dbcmd == null)
+ {
+ System.Console.WriteLine("Cannot create command");
+ }
+ dbcmd.CommandText = "DELETE FROM folders WHERE id > 1";
+ dbcmd.CommandType = CommandType.Text;
+ dbcmd.ExecuteNonQuery();
+ dbcmd.CommandText = "DELETE FROM documents";
+ dbcmd.CommandType = CommandType.Text;
+ dbcmd.ExecuteNonQuery();
+ dbcmd.CommandText = "DELETE FROM document_types_lookup WHERE name = 'NewType'";
+ dbcmd.ExecuteNonQuery();
+ dbcmd.CommandText = "INSERT INTO document_types_lookup(id,name) VALUES(2,'NewType')";
+ dbcmd.ExecuteNonQuery();
+ dbcmd.Dispose();
+ dbcmd = null;
+ dbcon.Close();
+ dbcon = null;
+ }
+ catch(Exception ex)
+ {
+ System.Console.WriteLine(ex.Message);
+ }
+ }
+
~KTTest()
{
this._kt.logout(this._session);
@@ -188,7 +229,7 @@ namespace MonoTests.KnowledgeTree
this.title = "kt unit test" + offset;
this.realFilename = "kt_unit_test" + offset + ".txt";
this.filename = (Helper.isUnix()?("/tmp/"):("c:\\")) + this.realFilename;
- this.content = "hello world!";
+ this.content = "Hello World!\nThis is a test! And more!\n\n\r\n";
this.docId = 0;
this.session = session;
this.kt = kt;
@@ -423,7 +464,6 @@ namespace MonoTests.KnowledgeTree
System.IO.FileStream inFile;
byte[] binaryData;
- string base64String = "";
try
{
diff --git a/ktwebservice/nunit/makefile b/ktwebservice/nunit/makefile
index 14d5c9b..236c43d 100644
--- a/ktwebservice/nunit/makefile
+++ b/ktwebservice/nunit/makefile
@@ -1,5 +1,4 @@
-RESULTS= authentication.result document_detail.result document_add.result document_checkout.result document_type.result document_links.result document_owner.result document_rename.result document_history.result document_workflow.result document_copy.result folder.result document_metadata.result document_system_metadata.result query.result
-#document_download.result
+RESULTS= authentication.result document_detail.result document_contents.result document_history.result folder.result document_metadata.result document_add.result document_checkout.result document_type.result document_links.result document_owner.result document_rename.result document_workflow.result document_copy.result document_system_metadata.result query.result document_download.result
PROXY=KTproxy.cs
WSDL=ktdms.wsdl
ROOT_URL=http://ktdms.trunk
@@ -9,10 +8,8 @@ all: ${RESULTS}
results: clean-results ${RESULTS}
-KTproxy.dll: KTproxy.cs helper.cs
- mcs -r:System.Web.Services /target:library KTproxy.cs helper.cs
-
-
+KTproxy.dll: KTproxy.cs helper.cs
+ mcs -r:System.Web.Services -r:System.Data.dll /target:library KTproxy.cs helper.cs
KTproxy.cs: ktdms.wsdl
wsdl -out:${PROXY} ${WSDL}
@@ -26,8 +23,8 @@ clean:
clean-results:
rm -f ${RESULTS}
-%.dll: %.cs KTproxy.dll
- mcs -r:System.Web.Services -r:nunit.framework /r:KTproxy.dll -debug /target:library -out:$@ $<
+%.dll: %.cs KTproxy.dll
+ mcs -r:System.Web.Services -r:nunit.framework /r:KTproxy.dll -debug /target:library -out:$@ $<
%.result: %.dll
(export KT_ROOT_URL=${ROOT_URL}; nunit-console $<)
diff --git a/ktwebservice/nunit/query.cs b/ktwebservice/nunit/query.cs
index 44cb4f2..96eb261 100644
--- a/ktwebservice/nunit/query.cs
+++ b/ktwebservice/nunit/query.cs
@@ -7,16 +7,16 @@ namespace MonoTests.KnowledgeTree
[TestFixture]
public class QueryTest : KTTest
{
-
+
[SetUp]
public void SetUp()
- {
+ {
}
[TearDown]
public void TearDown()
- {
+ {
}
[Test]
@@ -24,35 +24,38 @@ namespace MonoTests.KnowledgeTree
{
Document doc = new Document(0,this._session, this._kt, false, false);
doc.createFile(1);
- kt_search_response response = this._kt.search(this._session, "Filesize = \"13\"", "");
+ int filesize = doc.content.Length+1;
+ kt_search_response response = this._kt.search(this._session, "Filesize = \""+filesize+"\"", "");
Assert.AreEqual(0,response.status_code);
- Assert.AreEqual(doc.content.Length + 1,response.hits[0].filesize);
+ Assert.AreEqual("n/a", response.hits[0].custom_document_no);
+ Assert.AreEqual("n/a", response.hits[0].oem_document_no);
+ Assert.AreEqual(doc.content.Length + 1,response.hits[0].filesize);
Assert.AreEqual(doc.title,response.hits[0].title);
- Assert.AreEqual(doc.realFilename,response.hits[0].filename);
-
+ Assert.AreEqual(doc.realFilename,response.hits[0].filename);
+
response = this._kt.search(this._session, "DocumentId = \""+ response.hits[0].document_id +"\"", "");
Assert.AreEqual(0,response.status_code);
- Assert.AreEqual(doc.content.Length + 1,response.hits[0].filesize);
+ Assert.AreEqual(doc.content.Length + 1,response.hits[0].filesize);
Assert.AreEqual(doc.title,response.hits[0].title);
- Assert.AreEqual(doc.realFilename,response.hits[0].filename);
-
+ Assert.AreEqual(doc.realFilename,response.hits[0].filename);
+
response = this._kt.search(this._session, "Title = \""+ response.hits[0].title +"\"", "");
Assert.AreEqual(0,response.status_code);
- Assert.AreEqual(doc.content.Length + 1,response.hits[0].filesize);
+ Assert.AreEqual(doc.content.Length + 1,response.hits[0].filesize);
Assert.AreEqual(doc.title,response.hits[0].title);
- Assert.AreEqual(doc.realFilename,response.hits[0].filename);
-
-
+ Assert.AreEqual(doc.realFilename,response.hits[0].filename);
+
+
response = this._kt.search(this._session, "Filename = \""+ response.hits[0].filename +"\"", "");
Assert.AreEqual(0,response.status_code);
- Assert.AreEqual(doc.content.Length + 1,response.hits[0].filesize);
+ Assert.AreEqual(doc.content.Length + 1,response.hits[0].filesize);
Assert.AreEqual(doc.title,response.hits[0].title);
- Assert.AreEqual(doc.realFilename,response.hits[0].filename);
-
+ Assert.AreEqual(doc.realFilename,response.hits[0].filename);
+
doc.deleteFile();
}
}
diff --git a/ktwebservice/webservice.php b/ktwebservice/webservice.php
index 28efcd3..8ea5b33 100644
--- a/ktwebservice/webservice.php
+++ b/ktwebservice/webservice.php
@@ -59,7 +59,18 @@ if (defined('HAS_SEARCH_FUNCTIONALITY'))
require_once(KT_DIR . '/search2/search/search.inc.php');
}
-// TODO: Test getting files/metadata based on versioning works and implementation is consistent.
+// 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
+// TOdO: define more reason codes!
+// TODO: get_folder must have a 'create' option
+// TODO: redo metadata encoding
+// TODO: unit tests - metadata - test return values in selectin - list/tree
+// TODO: ktwsapi/php must be made compatible with v2/v3
+
+// NOTE: some features are not implemented yet. most expected for v3. e.g. oem_document_no, custom_document_no, download($version)., get_metadata($version)
// Status Codes as defined in the specification.
@@ -67,16 +78,24 @@ define('KTWS_SUCCESS', 0);
define('KTWS_ERR_INVALID_SESSION', 1);
define('KTWS_ERR_AUTHENTICATION_ERROR', 2);
define('KTWS_ERR_INSUFFICIENT_PERMISSIONS', 3);
+
define('KTWS_ERR_FILE_NOT_FOUND', 10);
define('KTWS_ERR_INVALID_FILENAME', 20);
+
define('KTWS_ERR_INVALID_DOCUMENT', 21);
define('KTWS_ERR_INVALID_FOLDER', 22);
define('KTWS_ERR_INVALID_METADATA', 23);
define('KTWS_ERR_INVALID_REASON', 24);
define('KTWS_ERR_INVALID_DEPTH', 25);
+define('KTWS_ERR_INVALID_DOCUMENT_TYPE', 26);
+
define('KTWS_ERR_PROBLEM', 98);
define('KTWS_ERR_DB_PROBLEM', 99);
+if (!defined('LATEST_WEBSERVICE_VERSION'))
+{
+ define('LATEST_WEBSERVICE_VERSION',2);
+}
function bool2str($bool)
{
@@ -120,7 +139,7 @@ class KTWebService
var $version;
var $ktapi;
-
+ static $wsclass = 'KTWebService';
function KTWebService()
{
@@ -182,7 +201,11 @@ class KTWebService
'id' => 'int',
'item_type' => 'string',
+ 'custom_document_no' => 'string',
+ 'oem_document_no' => 'string',
+
'title' => 'string',
+ 'document_type' => 'string',
'filename' => 'string',
'filesize' => 'string',
@@ -199,7 +222,7 @@ class KTWebService
'version' => 'string',
- 'immutable'=>'boolean',
+ 'is_immutable'=>'string',
'permissions' => 'string',
'workflow'=>'string',
@@ -258,23 +281,45 @@ class KTWebService
array(
'status_code'=>'int',
'message'=>'string',
+
+ 'document_id' => 'int',
+
+ 'custom_document_no' => 'string',
+ 'oem_document_no' => 'string',
+
'title' => 'string',
'document_type' => 'string',
- 'version' => 'string',
+ 'full_path' => 'string',
'filename' => 'string',
- 'created_date' => 'string',
+ 'filesize' => 'int',
+ 'folder_id' => 'int',
+
'created_by' => 'string',
- 'modified_date' => 'string',
+ 'created_date' => 'string',
+
+ 'checked_out_by'=>'string',
+ 'checked_out_date'=>'string',
+
'modified_by' => 'string',
- 'document_id' => 'int',
- 'folder_id' => 'int',
+ 'modified_date' => 'string',
+
+ 'owned_by'=>'string',
+
+ 'version' => 'float',
+
+ 'is_immutable'=>'boolean',
+ 'permissions' => 'string',
+
'workflow' => 'string',
'workflow_state' => 'string',
- 'full_path' => 'string',
- 'owner'=>'string',
- 'is_immutable'=>'boolean',
- 'checked_out_date'=>'string',
- 'checked_out_by'=>'string',
+
+ 'mime_type' => 'string',
+ 'mime_icon_path' => 'string',
+ 'mime_display' => 'string',
+
+ 'storage_path' => 'string',
+
+
'metadata' => "{urn:$this->namespace}kt_metadata_fieldsets",
'links' => "{urn:$this->namespace}kt_linked_documents",
'transitions' => "{urn:$this->namespace}kt_workflow_transitions",
@@ -289,25 +334,44 @@ class KTWebService
$this->__typedef["{urn:$this->namespace}kt_search_result_item"] =
array(
'document_id' => 'int',
+
+ 'custom_document_no' => 'string',
+ 'oem_document_no' => 'string',
+
'relevance' => 'float',
'text' => 'string',
+
'title' => 'string',
+ 'document_type' => 'string',
'fullpath' => 'string',
- 'filesize' => 'int',
- 'version' => 'string',
- 'filename' => 'string',
+ 'filename' => 'string',
+ 'filesize' => 'int',
'folder_id' => 'int',
- 'workflow' => 'string',
- 'workflow_state' => 'string',
- 'mime_type' => 'string',
- 'owner' => 'string',
+
'created_by' => 'string',
'created_date' => 'string',
- 'modified_by' => 'string',
- 'modified_date' => 'string',
+
'checked_out_by' => 'string',
'checked_out_date' => 'string',
+
+ 'modified_by' => 'string',
+ 'modified_date' => 'string',
+
+ 'owned_by' => 'string',
+
+ 'version' => 'float',
'is_immutable' => 'boolean',
+ 'permissions' => 'string',
+
+ 'workflow' => 'string',
+ 'workflow_state' => 'string',
+
+ 'mime_type' => 'string',
+ 'mime_icon_path' => 'string',
+ 'mime_display' => 'string',
+
+ 'storage_path' => 'string',
+
'status' => 'string',
);
@@ -351,7 +415,6 @@ class KTWebService
'parent_id' => 'int'
);
-
$this->__typedef["{urn:$this->namespace}kt_metadata_selection"] =
array(
array(
@@ -359,7 +422,6 @@ class KTWebService
)
);
-
$this->__typedef["{urn:$this->namespace}kt_metadata_field"] =
array(
'name' => 'string',
@@ -421,11 +483,27 @@ class KTWebService
'datetime' => 'string'
);
+ if ($this->version >= 2)
+ {
+ $this->__typedef["{urn:$this->namespace}kt_document_transaction_history_item"] =
+ array(
+ 'transaction_name'=>'string',
+ 'username'=>'string',
+ 'version' => 'float',
+ 'comment' => 'string',
+ 'datetime' => 'string'
+ );
+ }
+
$this->__typedef["{urn:$this->namespace}kt_linked_document"] =
array(
'document_id'=>'int',
- 'title'=>'string',
- 'size' => 'int',
+ 'custom_document_no' => 'string',
+ 'oem_document_no' => 'string',
+ 'title'=>'string',
+ 'document_type'=>'string',
+ 'filesize' => 'int',
+ 'version' => 'float',
'workflow' => 'string',
'workflow_state' => 'string',
'link_type' => 'string'
@@ -467,6 +545,16 @@ class KTWebService
'content_version'=>'string',
);
+ if ($this->version >= 2)
+ {
+ $this->__typedef["{urn:$this->namespace}kt_document_version_history_item"] =
+ array(
+ 'user'=>'string',
+ 'metadata_version'=>'int',
+ 'content_version'=>'float',
+ );
+ }
+
$this->__typedef["{urn:$this->namespace}kt_document_version_history"] =
array(
array(
@@ -509,7 +597,6 @@ class KTWebService
)
);
-
$this->__typedef["{urn:$this->namespace}kt_client_policies_response"] =
array(
'status_code' => 'int',
@@ -520,7 +607,6 @@ class KTWebService
/* methods */
if (defined('HAS_SEARCH_FUNCTIONALITY'))
{
-
$this->__dispatch_map['search'] = array(
'in' => array('session_id' => 'string', 'search'=>'string' ,'options'=>'string'),
'out' => array('return' => "{urn:$this->namespace}kt_search_response" ),
@@ -539,7 +625,6 @@ class KTWebService
'out' => array('return' => "{urn:$this->namespace}kt_response" ),
);
-
// logout
$this->__dispatch_map['logout'] =
array('in' => array('session_id' => 'string' ),
@@ -552,12 +637,22 @@ class KTWebService
'out' => array('return' => "{urn:$this->namespace}kt_folder_detail"),
);
+ if ($this->version >=3)
+ {
+ $this->__dispatch_map['get_folder_detail']['in'] = array('session_id' => 'string', 'folder_id' => 'int', 'create'=>'boolean' );
+ }
+
// get_folder_detail_by_name
$this->__dispatch_map['get_folder_detail_by_name'] =
array('in' => array('session_id' => 'string', 'folder_name' => 'string' ),
'out' => array('return' => "{urn:$this->namespace}kt_folder_detail"),
);
+ if ($this->version >=3)
+ {
+ $this->__dispatch_map['get_folder_detail_by_name']['in'] = array('session_id' => 'string', 'folder_id' => 'int', 'create'=>'boolean' );
+ }
+
// get_folder_contents
$this->__dispatch_map['get_folder_contents'] =
array('in' => array('session_id'=>'string','folder_id'=>'int','depth'=>'int','what'=>'string'),
@@ -580,7 +675,6 @@ class KTWebService
);
}
-
// delete_folder
$this->__dispatch_map['delete_folder'] =
array('in' => array('session_id'=>'string','folder_id'=>'int','reason' =>'string'),
@@ -635,7 +729,6 @@ class KTWebService
$this->__dispatch_map['get_document_detail']['in'] = array('session_id' => 'string', 'document_id' => 'int', 'detail'=>'string' );
}
-
// checkin_document
$this->__dispatch_map['checkin_document'] =
array('in' => array('session_id'=>'string','document_id'=>'int','filename'=>'string','reason' =>'string','tempfilename' =>'string', 'major_update'=>'boolean' ),
@@ -666,7 +759,6 @@ class KTWebService
array('in' => array('session_id'=>'string','document_id'=>'int','filename'=>'string','reason' =>'string','tempfilename' =>'string', 'major_update'=>'boolean', 'metadata'=>"{urn:$this->namespace}kt_metadata_fieldsets",'sysdata'=>"{urn:$this->namespace}kt_sysdata" ),
'out' => array( 'return' => "{urn:$this->namespace}kt_document_detail" )
);
-
}
// add_document
@@ -701,12 +793,8 @@ class KTWebService
array('in' => array('session_id'=>'string','folder_id'=>'int','title'=>'string','filename'=>'string','documentype' =>'string','tempfilename' =>'string', 'metadata'=>"{urn:$this->namespace}kt_metadata_fieldsets",'sysdata'=>"{urn:$this->namespace}kt_sysdata" ),
'out' => array( 'return' => "{urn:$this->namespace}kt_document_detail" )
);
-
-
}
-
-
// get_document_detail_by_name
$this->__dispatch_map['get_document_detail_by_name'] =
array('in' => array('session_id' => 'string', 'document_name' => 'string', 'what'=>'string' ),
@@ -742,7 +830,6 @@ class KTWebService
);
}
-
// checkout_small_document
$this->__dispatch_map['checkout_small_document'] =
array('in' => array('session_id'=>'string','document_id'=>'int','reason' =>'string','download' => 'boolean'),
@@ -754,7 +841,6 @@ class KTWebService
$this->__dispatch_map['checkout_small_document']['out'] = array('return' => "{urn:$this->namespace}kt_document_detail" );
}
-
// checkout_base64_document
$this->__dispatch_map['checkout_base64_document'] =
array('in' => array('session_id'=>'string','document_id'=>'int','reason' =>'string','download' => 'boolean'),
@@ -767,7 +853,6 @@ class KTWebService
$this->__dispatch_map['checkout_base64_document']['out'] = array('return' => "{urn:$this->namespace}kt_document_detail" );
}
-
// undo_document_checkout
$this->__dispatch_map['undo_document_checkout'] =
array('in' => array('session_id'=>'string','document_id'=>'int','reason' =>'string'),
@@ -779,8 +864,6 @@ class KTWebService
$this->__dispatch_map['undo_document_checkout']['out'] = array('return' => "{urn:$this->namespace}kt_document_detail" );
}
-
-
// download_document
$this->__dispatch_map['download_document'] =
array('in' => array('session_id'=>'string','document_id'=>'int' ),
@@ -800,13 +883,19 @@ class KTWebService
'alias' => 'download_small_document'
);
+ if ($this->version >= 3)
+ {
+ $this->__dispatch_map['download_document']['in'] = array('session_id'=>'string','document_id'=>'int', 'version'=>'string' );
+ $this->__dispatch_map['download_small_document']['in'] = array('session_id'=>'string','document_id'=>'int', 'version'=>'string' );
+ $this->__dispatch_map['download_base64_document']['in'] = array('session_id'=>'string','document_id'=>'int', 'version'=>'string' );
+ }
+
// delete_document
$this->__dispatch_map['delete_document'] =
array('in' => array('session_id'=>'string','document_id'=>'int','reason'=>'string'),
'out' => array( 'return' => "{urn:$this->namespace}kt_response" ),
);
-
// change_document_owner
$this->__dispatch_map['change_document_owner'] =
array('in' => array('session_id'=>'string','document_id'=>'int','username'=>'string','reason'=>'string'),
@@ -818,7 +907,6 @@ class KTWebService
$this->__dispatch_map['change_document_owner']['out'] = array( 'return' => "{urn:$this->namespace}kt_document_detail" );
}
-
// copy_document
$this->__dispatch_map['copy_document'] =
array('in' => array('session_id'=>'string','document_id'=>'int','folder_id'=>'int','reason'=>'string','newtitle'=>'string','newfilename'=>'string'),
@@ -858,7 +946,6 @@ class KTWebService
$this->__dispatch_map['rename_document_filename']['out'] = array( 'return' => "{urn:$this->namespace}kt_document_detail" );
}
-
// change_document_type
$this->__dispatch_map['change_document_type'] =
array('in' => array('session_id'=>'string','document_id'=>'int', 'documenttype'=>'string' ),
@@ -916,6 +1003,11 @@ class KTWebService
'out' => array( 'return' => "{urn:$this->namespace}kt_metadata_response" ),
);
+ if ($this->version >= 3)
+ {
+ $this->__dispatch_map['get_document_metadata']['in'] = array('session_id'=>'string','document_id'=>'int', 'version'=>'string');
+ }
+
// get_document_type_metadata
$this->__dispatch_map['get_document_type_metadata'] =
array('in' => array('session_id'=>'string','document_type'=>'string' ),
@@ -934,17 +1026,14 @@ class KTWebService
'out' => array( 'return' => "{urn:$this->namespace}kt_document_detail" )
);
-
}
-
//get_document_workflow_transitions
$this->__dispatch_map['get_document_workflow_transitions'] =
array('in' => array('session_id'=>'string','document_id'=>'int' ),
'out' => array( 'return' => "{urn:$this->namespace}kt_workflow_transitions_response" ),
);
-
//get_document_workflow_state
$this->__dispatch_map['get_document_workflow_state'] =
array('in' => array('session_id'=>'string','document_id'=>'int' ),
@@ -957,7 +1046,6 @@ class KTWebService
'out' => array( 'return' => "{urn:$this->namespace}kt_document_transaction_history_response" ),
);
-
// get_document_version_history
$this->__dispatch_map['get_document_version_history'] =
array('in' => array('session_id'=>'string','document_id'=>'int' ),
@@ -982,7 +1070,21 @@ class KTWebService
'out' => array( 'return' => "{urn:$this->namespace}kt_client_policies_response" ),
);
+ if ($this->version >= 2)
+ {
+ $this->__dispatch_map['get_client_policies']['in'] = array('session_id'=>'string', 'client'=>'string');
+ }
+ }
+ function get()
+ {
+ static $ws = null;
+ if (is_null($ws))
+ {
+ $classname = KTWebService::$wsclass;
+ $ws = new $classname();
+ }
+ return $ws;
}
function debug($msg, $function = null, $level=0)
@@ -1012,6 +1114,14 @@ class KTWebService
}
}
+ function _status($code, $message='')
+ {
+ if (PEAR::isError($message))
+ {
+ $message = $message->getMessage();
+ }
+ return array('status_code'=>$code, 'message'=>$message);
+ }
/**
* This is used by all exposed functions dependant on the sessionid.
@@ -1032,12 +1142,7 @@ class KTWebService
if ( PEAR::isError($session))
{
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_SESSION,
- 'message'=>$session->getMessage()
- );
-
- return $response;
+ return KTWebService::_status(KTWS_ERR_INVALID_SESSION,$session);
}
$this->ktapi = $kt;
return $kt;
@@ -1051,10 +1156,7 @@ class KTWebService
*/
function anonymous_login($ip=null)
{
- $response = array(
- 'status_code'=>KTWS_ERR_AUTHENTICATION_ERROR,
- 'message'=>'',
- );
+ $response = KTWebService::_status(KTWS_ERR_AUTHENTICATION_ERROR);
$kt = new KTAPI();
@@ -1086,10 +1188,7 @@ class KTWebService
*/
function login($username, $password, $ip=null)
{
- $response = array(
- 'status_code'=>KTWS_ERR_AUTHENTICATION_ERROR,
- 'message'=>'',
- );
+ $response = KTWebService::_status(KTWS_ERR_AUTHENTICATION_ERROR);
$kt = new KTAPI();
@@ -1126,10 +1225,7 @@ class KTWebService
return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $kt);
}
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_SESSION,
- 'message'=>''
- );
+ $response = KTWebService::_status(KTWS_ERR_INVALID_SESSION);
$session = &$kt->get_session();
if (PEAR::isError($session))
@@ -1164,10 +1260,7 @@ class KTWebService
$folder = &$kt->get_folder_by_id($folder_id);
if (PEAR::isError($folder))
{
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_FOLDER,
- 'message'=>$folder->getMessage()
- );
+ $response = KTWebService::_status(KTWS_ERR_INVALID_FOLDER,$folder);
$this->debug("get_folder_detail - " . $folder->getMessage(), $session_id);
return new SOAP_Value('return',"{urn:$this->namespace}kt_folder_detail", $response);
}
@@ -1198,10 +1291,7 @@ class KTWebService
$folder = &$kt->get_folder_by_name($folder_name);
if (PEAR::isError($folder))
{
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_FOLDER,
- 'message'=>$folder->getMessage()
- );
+ $response = KTWebService::_status(KTWS_ERR_INVALID_FOLDER,$folder);
$this->debug("get_folder_detail_by_name - cannot get folder $folder_name - " . $folder->getMessage(), $session_id);
return new SOAP_Value('return',"{urn:$this->namespace}kt_folder_detail", $response);
}
@@ -1211,48 +1301,6 @@ class KTWebService
$detail['message']='';
return new SOAP_Value('return',"{urn:$this->namespace}kt_folder_detail", $detail);
-
- }
-
- /**
- * Encodes an array as kt_folder_item
- *
- * @param array $item
- * @param string $name
- * @return SOAP_Value of kt_folder_item
- * @access private
- * @static
- */
- function _encode_folder_item($item, $name='item')
- {
- $item['id'] = (int) $item['id'];
-
- if (!empty($item['items']))
- {
- $item['items'] = KTWebService::_encode_folder_items($item['items']);
- }
-
- return new SOAP_Value($name,"{urn:$this->namespace}kt_folder_item", $item);
- }
-
- /**
- * Encodes an array as kt_folder_items
- *
- * @param array $items
- * @param string $name
- * @return SOAP_Value of kt_folder_items
- * @access private
- * @static
- */
- function _encode_folder_items($items, $name='items')
- {
- $encoded=array();
- foreach($items as $item)
- {
- $encoded[] = KTWebService::_encode_folder_item($item);
- }
-
- return new SOAP_Value($name,"{urn:$this->namespace}kt_folder_items", $encoded);
}
/**
@@ -1264,12 +1312,17 @@ class KTWebService
* @access private
* @static
*/
- function _encode_folder_contents($contents, $name='return')
+ function _encode_folder_items($items)
{
- $contents['items'] = KTWebService::_encode_folder_items($contents['items']);
- return new SOAP_Value($name,"{urn:$this->namespace}kt_folder_contents", $contents);
- }
+ foreach($items as $key=>$item)
+ {
+ $item['id'] = (int) $item['id'];
+ $item['items'] = KTWebService::_encode_folder_items($item['items']);
+ $items[$key] = new SOAP_Value('item',"{urn:$this->namespace}kt_folder_item", $item);
+ }
+ return new SOAP_Value('items',"{urn:$this->namespace}kt_folder_items", $items);
+ }
/**
* Returns the contents of a folder.
@@ -1292,10 +1345,8 @@ class KTWebService
$folder = &$kt->get_folder_by_id($folder_id);
if (PEAR::isError($folder))
{
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_FOLDER,
- 'message'=>$folder->getMessage()
- );
+ $response = KTWebService::_status(KTWS_ERR_INVALID_FOLDER,$folder);
+
$this->debug("get_folder_contents - cannot get folderid $folder_id - " . $folder->getMessage(), $session_id);
return new SOAP_Value('return',"{urn:$this->namespace}kt_folder_contents", $response);
}
@@ -1308,10 +1359,10 @@ class KTWebService
'folder_id' => $folder_id+0,
'folder_name'=>$folder->get_folder_name(),
'full_path'=>$folder->get_full_path(),
- 'items'=>$listing
+ 'items'=>KTWebService::_encode_folder_items($listing)
);
- return KTWebService::_encode_folder_contents($contents);
+ return new SOAP_Value($name,"{urn:$this->namespace}kt_folder_contents", $contents);
}
/**
@@ -1335,10 +1386,8 @@ class KTWebService
$folder = &$kt->get_folder_by_id($folder_id);
if (PEAR::isError($folder))
{
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_FOLDER,
- 'message'=>$folder->getMessage()
- );
+ $response = KTWebService::_status(KTWS_ERR_INVALID_FOLDER,$folder);
+
$this->debug("create_folder - cannot get folderid $folder_id - " . $folder->getMessage(), $session_id);
return new SOAP_Value('return',"{urn:$this->namespace}kt_folder_detail", $response);
@@ -1347,10 +1396,7 @@ class KTWebService
$newfolder = &$folder->add_folder($folder_name);
if (PEAR::isError($newfolder))
{
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_FOLDER,
- 'message'=>$newfolder->getMessage()
- );
+ $response = KTWebService::_status(KTWS_ERR_INVALID_FOLDER,$newfolder);
$this->debug("create_folder - cannot create folder $folder_name - " . $folder->getMessage(), $session_id);
return new SOAP_Value('return',"{urn:$this->namespace}kt_folder_detail", $response);
@@ -1380,10 +1426,7 @@ class KTWebService
return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $kt);
}
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_FOLDER,
- 'message'=>''
- );
+ $response = KTWebService::_status(KTWS_ERR_INVALID_FOLDER);
$folder = &$kt->get_folder_by_id($folder_id);
if (PEAR::isError($folder))
@@ -1424,10 +1467,7 @@ class KTWebService
return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $kt);
}
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_FOLDER,
- 'message'=>''
- );
+ $response = KTWebService::_status(KTWS_ERR_INVALID_FOLDER);
$folder = &$kt->get_folder_by_id($folder_id);
if (PEAR::isError($folder))
@@ -1469,10 +1509,7 @@ class KTWebService
return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $kt);
}
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_FOLDER,
- 'message'=>''
- );
+ $response = KTWebService::_status(KTWS_ERR_INVALID_FOLDER);
$src_folder = &$kt->get_folder_by_id($source_id);
if (PEAR::isError($src_folder))
@@ -1524,10 +1561,7 @@ class KTWebService
return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $kt);
}
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_FOLDER,
- 'message'=>''
- );
+ $response = KTWebService::_status(KTWS_ERR_INVALID_FOLDER);
$src_folder = &$kt->get_folder_by_id($source_id);
if (PEAR::isError($src_folder))
@@ -1574,10 +1608,7 @@ class KTWebService
return new SOAP_Value('return',"{urn:$this->namespace}kt_document_types_response", $kt);
}
- $response=array(
- 'status_code'=>KTWS_ERR_PROBLEM,
- 'message'=>''
- );
+ $response = KTWebService::_status(KTWS_ERR_PROBLEM);
$result = $kt->get_documenttypes();
if (PEAR::isError($result))
@@ -1604,10 +1635,7 @@ class KTWebService
return new SOAP_Value('return',"{urn:$this->namespace}kt_document_types_response", $kt);
}
- $response=array(
- 'status_code'=>KTWS_ERR_PROBLEM,
- 'message'=>''
- );
+ $response = KTWebService::_status(KTWS_ERR_PROBLEM);
$result = $kt->get_document_link_types();
if (PEAR::isError($result))
@@ -1644,10 +1672,8 @@ class KTWebService
$document = $kt->get_document_by_id($document_id);
if (PEAR::isError($document))
{
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_DOCUMENT,
- 'message'=>$document->getMessage()
- );
+ $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT,$document);
+
$this->debug("get_document_detail - cannot get documentid $document_id - " . $document->getMessage(), $session_id);
return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $response);
@@ -1676,35 +1702,59 @@ class KTWebService
$detail['version_history'] = array();
$detail['transaction_history'] = array();
-
if (stripos($detailstr,'M') !== false)
{
$response = $this->get_document_metadata($session_id, $document_id);
$detail['metadata'] = $response->value['metadata'];
+ $detail['metadata']->name = 'metadata';
+ }
+ else
+ {
+ $detail['metadata'] = KTWebService::_encode_metadata_fields($detail['metadata']);
}
if (stripos($detailstr,'L') !== false)
{
- $response = $this->get_document_metadata($session_id, $document_id);
+ $response = $this->get_document_links($session_id, $document_id);
$detail['links'] = $response->value['links'];
+ $detail['links']->name = 'links';
+ }
+ else
+ {
+ $detail['links'] = KTWebService::_encode_document_links($detail['links']);
}
if (stripos($detailstr,'T') !== false)
{
$response = $this->get_document_workflow_transitions($session_id, $document_id);
- $detail['transitions'] = $response->value['transitions'];
+ $detail['transitions'] = $response->value['transitions'] ;
+ $detail['transitions']->name = 'transitions';
+ }
+ else
+ {
+ $detail['transitions'] = KTWebService::_encode_document_workflow_transitions($detail['transitions']);
}
if (stripos($detailstr,'V') !== false)
{
$response = $this->get_document_version_history($session_id, $document_id);
- $detail['version_history'] = $response->value['history'];
+ $detail['version_history'] = $response->value['history'];
+ $detail['version_history']->name = 'version_history';
+ }
+ else
+ {
+ $detail['version_history'] = KTWebService::_encode_version_history($detail['version_history'],'version_history');
}
if (stripos($detailstr,'H') !== false)
{
$response = $this->get_document_transaction_history($session_id, $document_id);
- $detail['transaction_history'] = $response->value['history'];
+ $detail['transaction_history'] = $response->value['history'];
+ $detail['transaction_history']->name = 'transaction_history';
+ }
+ else
+ {
+ $detail['transaction_history'] = KTWebService::_encode_transaction_history($detail['transaction_history'],'transaction_history');
}
}
@@ -1734,10 +1784,9 @@ class KTWebService
function get_document_detail_by_name($session_id, $folder_id, $document_name, $what='T', $detail='')
{
$this->debug("get_document_detail_by_name('$session_id','$document_name','$what','$detail')");
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_FOLDER,
- 'message'=>''
- );
+
+ $response = KTWebService::_status(KTWS_ERR_INVALID_FOLDER);
+
if (empty($document_name))
{
$response['message'] = 'Document_name is empty.';
@@ -1785,64 +1834,7 @@ class KTWebService
return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $response);
}
- $detailstr = $detail;
-
- $detail = $document->get_detail();
- if (PEAR::isError($detail))
- {
- $response['status_code'] = KTWS_ERR_PROBLEM;
- $response['message'] = $detail->getMessage();
-
- $this->debug("get_document_detail_by_name - cannot get document detail - " . $detail->getMessage(), $session_id);
-
- return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $response);
- }
-
- $detail['status_code']=KTWS_SUCCESS;
- $detail['message']='';
-
-
- if ($this->version >= 2)
- {
-
- $detail['metadata'] = array();
- $detail['links'] = array();
- $detail['transitions'] = array();
- $detail['version_history'] = array();
- $detail['transaction_history'] = array();
-
- if (stripos($detailstr,'M') !== false)
- {
- $response = $this->get_document_metadata($session_id, $document_id);
- $detail['metadata'] = $response->value['metadata'];
- }
-
- if (stripos($detailstr,'L') !== false)
- {
- $response = $this->get_document_metadata($session_id, $document_id);
- $detail['links'] = $response->value['links'];
- }
-
- if (stripos($detailstr,'T') !== false)
- {
- $response = $this->get_document_workflow_transitions($session_id, $document_id);
- $detail['transitions'] = $response->value['transitions'];
- }
-
- if (stripos($detailstr,'V') !== false)
- {
- $response = $this->get_document_version_history($session_id, $document_id);
- $detail['version_history'] = $response->value['history'];
- }
-
- if (stripos($detailstr,'H') !== false)
- {
- $response = $this->get_document_transaction_history($session_id, $document_id);
- $detail['transaction_history'] = $response->value['history'];
- }
- }
-
- return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $detail);
+ return $this->get_document_detail($session_id, $document->documentid, $detail);
}
/**
@@ -1868,15 +1860,11 @@ class KTWebService
// we need to add some security to ensure that people don't frig the checkin process to access restricted files.
// possibly should change 'tempfilename' to be a hash or id of some sort if this is troublesome.
$upload_manager = new KTUploadManager();
- $tempdir = substr($tempfilename,0,strlen($upload_manager->temp_dir));
- if ($tempdir != $upload_manager->temp_dir)
+ if (!$upload_manager->is_valid_temporary_file($tempfilename))
{
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_FOLDER,
- 'message'=>'Invalid temporary file.'
- );
+ $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT,"Invalid temporary file: $tempfilename. Not compatible with $upload_manager->temp_dir.");
- $this->debug("add_document - $upload_manager->temp_dir != $tempdir", $session_id);
+ $this->debug("add_document - Invalid temporary file: $tempfilename. Not compatible with $upload_manager->temp_dir.", $session_id);
return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $response);
}
@@ -1884,10 +1872,7 @@ class KTWebService
$folder = &$kt->get_folder_by_id($folder_id);
if (PEAR::isError($folder))
{
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_FOLDER,
- 'message'=>$folder->getMessage()
- );
+ $response = KTWebService::_status(KTWS_ERR_INVALID_FOLDER,$folder);
$this->debug("add_document - cannot get folder $folder_id - " . $folder->getMessage(), $session_id);
@@ -1897,13 +1882,8 @@ class KTWebService
$document = &$folder->add_document($title, $filename, $documenttype, $tempfilename);
if (PEAR::isError($document))
{
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_DOCUMENT,
- 'message'=>$document->getMessage()
- );
-
+ $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT,$document);
$this->debug("add_document - cannot add document - " . $document->getMessage(), $session_id);
-
return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $response);
}
@@ -1982,8 +1962,6 @@ class KTWebService
return $update_result;
}
-
-
/**
* Adds a document to the repository.
*
@@ -2001,77 +1979,37 @@ class KTWebService
$kt = &$this->get_ktapi($session_id );
if (is_array($kt))
{
- return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $kt);
- }
-
- // create a temporary file
- $oConfig = KTConfig::getSingleton();
- $tmp_dir = $oConfig->get('webservice/uploadDirectory');
-
- $tempfilename = tempnam($tmp_dir,'sa_');
- if (!is_writable($tempfilename))
- {
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_FOLDER,
- 'message'=>'Cannot write to temp folder: ' + $tempfilename
- );
- $this->debug("add_small_document - cannot write $tempfilename", $session_id);
-
- return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $response);
- }
-
- // we need to add some security to ensure that people don't frig the checkin process to access restricted files.
- // possibly should change 'tempfilename' to be a hash or id of some sort if this is troublesome.
- $upload_manager = new KTUploadManager();
- $tempdir = substr($tempfilename,0,strlen($upload_manager->temp_dir));
- if ( $tempdir != $upload_manager->temp_dir)
- {
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_FOLDER,
- 'message'=>'Invalid temporary file.'
- );
-
- $this->debug("add_small_document - $upload_manager->temp_dir != $tempdir ", $session_id);
-
- return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $response);
+ return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $kt);
}
$folder = &$kt->get_folder_by_id($folder_id);
if (PEAR::isError($folder))
{
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_FOLDER,
- 'message'=>$folder->getMessage()
- );
+ $response = KTWebService::_status(KTWS_ERR_INVALID_FOLDER,$folder);
$this->debug("add_small_document - cannot get folderid $folder_id - " . $folder->getMessage(), $session_id);
return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $response);
}
- // write to the temporary file
- $fp=fopen($tempfilename, 'wb');
- if ($fp === false)
- {
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_DOCUMENT,
- 'message'=>'Cannot write to temp file: ' + $tempfilename
- );
- $this->debug("add_small_document - cannot get folderid $folder_id" , $session_id);
+ $upload_manager = new KTUploadManager();
+ $tempfilename = $upload_manager->store_base64_file($base64);
+ if (PEAR::isError($tempfilename))
+ {
+ $reason = $tempfilename->getMessage();
+ $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT,'Cannot write to temp file: ' + $tempfilename . ". Reason: $reason");
+ $this->debug("add_small_document - cannot write $tempfilename. Reason: $reason", $session_id);
+
return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $response);
- }
- fwrite($fp, base64_decode($base64));
- fclose($fp);
+ }
// simulate the upload
- $upload_manager->uploaded($filename,$tempfilename, 'A');
+ $tempfilename = $upload_manager->uploaded($filename,$tempfilename, 'A');
// add the document
$document = &$folder->add_document($title, $filename, $documenttype, $tempfilename);
if (PEAR::isError($document))
{
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_DOCUMENT,
- 'message'=>$document->getMessage()
- );
+ $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT,$document);
+
$this->debug("add_small_document - cannot add document - " . $document->getMessage(), $session_id);
return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $response);
}
@@ -2103,16 +2041,12 @@ class KTWebService
return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $kt);
}
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_DOCUMENT,
- 'message'=>'',
- );
+ $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT);
- // we need to add some security to ensure that people don't frig the checkin process to access restricted files.
+ // we need to add some security to ensure that people don't frig the checkin process to access restricted files.
// possibly should change 'tempfilename' to be a hash or id of some sort if this is troublesome.
$upload_manager = new KTUploadManager();
- $tempdir = substr($tempfilename,0,strlen($upload_manager->temp_dir));
- if ($tempdir != $upload_manager->temp_dir)
+ if (!$upload_manager->is_valid_temporary_file($tempfilename))
{
$response['message'] = 'Invalid temporary file';
$this->debug("checkin_document - $upload_manager->temp_dir != $tempdir", $session_id);
@@ -2141,9 +2075,8 @@ class KTWebService
return $this->get_document_detail($session_id, $document_id);
}
-
- function checkin_small_document_with_metadata($session_id, $document_id, $filename, $reason, $base64, $major_update, $metadata, $sysdata)
- {
+ function checkin_small_document_with_metadata($session_id, $document_id, $filename, $reason, $base64, $major_update, $metadata, $sysdata)
+ {
$add_result = $this->checkin_small_document($session_id, $document_id, $filename, $reason, $base64, $major_update);
$status_code = $add_result->value['status_code'];
@@ -2173,10 +2106,10 @@ class KTWebService
}
return $update_result;
- }
+ }
- function checkin_document_with_metadata($session_id, $document_id, $filename, $reason, $tempfilename, $major_update, $metadata, $sysdata)
- {
+ function checkin_document_with_metadata($session_id, $document_id, $filename, $reason, $tempfilename, $major_update, $metadata, $sysdata)
+ {
$add_result = $this->checkin_document($session_id, $document_id, $filename, $reason, $tempfilename, $major_update);
$status_code = $add_result->value['status_code'];
@@ -2206,7 +2139,7 @@ class KTWebService
}
return $update_result;
- }
+ }
/**
@@ -2229,55 +2162,21 @@ class KTWebService
return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $kt);
}
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_DOCUMENT,
- 'message'=>'',
- );
-
- // create a temporary file
- $oConfig = KTConfig::getSingleton();
- $tmp_dir = $oConfig->get('webservice/uploadDirectory');
-
- $tempfilename = tempnam($tmp_dir,'su_');
- if (!is_writable($tempfilename))
- {
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_FOLDER,
- 'message'=>'Cannot write to temp folder: ' + $tempfilename
- );
-
- $this->debug("checkin_small_document - $tempfilename is not writable", $session_id);
-
- return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $response);
- }
+ $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT);
- // we need to add some security to ensure that people don't frig the checkin process to access restricted files.
- // possibly should change 'tempfilename' to be a hash or id of some sort if this is troublesome.
$upload_manager = new KTUploadManager();
- $tempdir = substr($tempfilename,0,strlen($upload_manager->temp_dir));
- if ($tempdir != $upload_manager->temp_dir)
+ $tempfilename = $upload_manager->store_base64_file($base64, 'su_');
+ if (PEAR::isError($tempfilename))
{
- $response['message'] = 'Invalid temporary file';
- $this->debug("checkin_small_document - $upload_manager->temp_dir != $tempdir", $session_id);
- return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $response);
- }
+ $reason = $tempfilename->getMessage();
+ $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT,'Cannot write to temp file: ' + $tempfilename . ". Reason: $reason");
+ $this->debug("checkin_small_document - cannot write $tempfilename. Reason: $reason", $session_id);
- // write to the temporary file
- $fp=fopen($tempfilename, 'wb');
- if ($fp === false)
- {
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_DOCUMENT,
- 'message'=>'Cannot write to temp file: ' + $tempfilename
- );
- $this->debug("checkin_small_document - cannot write $tempfilename", $session_id);
return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $response);
- }
- fwrite($fp, base64_decode($base64));
- fclose($fp);
+ }
// simulate the upload
- $upload_manager->uploaded($filename,$tempfilename, 'C');
+ $tempfilename = $upload_manager->uploaded($filename,$tempfilename, 'C');
$document = &$kt->get_document_by_id($document_id);
if (PEAR::isError($document))
@@ -2316,10 +2215,7 @@ class KTWebService
return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $kt);
}
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_DOCUMENT,
- 'message'=>''
- );
+ $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT);
$document = &$kt->get_document_by_id($document_id);
if (PEAR::isError($document))
@@ -2381,10 +2277,7 @@ class KTWebService
return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $kt);
}
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_DOCUMENT,
- 'message'=>''
- );
+ $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT);
$document = &$kt->get_document_by_id($document_id);
if (PEAR::isError($document))
@@ -2455,10 +2348,7 @@ class KTWebService
return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $kt);
}
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_DOCUMENT,
- 'message'=>''
- );
+ $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT);
$document = &$kt->get_document_by_id($document_id);
if (PEAR::isError($document))
@@ -2496,7 +2386,7 @@ class KTWebService
* @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)
+ function download_document($session_id, $document_id, $version=null)
{
$this->debug("download_document('$session_id',$document_id)");
@@ -2506,10 +2396,7 @@ class KTWebService
return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $kt);
}
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_DOCUMENT,
- 'message'=>''
- );
+ $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT);
$document = &$kt->get_document_by_id($document_id);
if (PEAR::isError($document))
@@ -2548,7 +2435,7 @@ class KTWebService
* @return kt_response. status_code can be KTWS_ERR_INVALID_SESSION, KTWS_ERR_INVALID_DOCUMENT or KTWS_SUCCESS
*/
- function download_small_document($session_id, $document_id)
+ function download_small_document($session_id, $document_id, $version=null)
{
$this->debug("download_small_document('$session_id',$document_id)");
@@ -2558,10 +2445,7 @@ class KTWebService
return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $kt);
}
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_DOCUMENT,
- 'message'=>''
- );
+ $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT);
$document = &$kt->get_document_by_id($document_id);
if (PEAR::isError($document))
@@ -2620,10 +2504,8 @@ class KTWebService
{
return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $kt);
}
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_DOCUMENT,
- 'message'=>''
- );
+
+ $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT);
$document = &$kt->get_document_by_id($document_id);
if (PEAR::isError($document))
@@ -2670,10 +2552,8 @@ class KTWebService
{
return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $kt);
}
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_DOCUMENT,
- 'message'=>''
- );
+
+ $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT);
$document = &$kt->get_document_by_id($document_id);
if (PEAR::isError($document))
@@ -2687,6 +2567,7 @@ class KTWebService
$result = $document->change_document_type($documenttype);
if (PEAR::isError($result))
{
+ $response['status_code'] = KTWS_ERR_INVALID_DOCUMENT_TYPE;
$response['message'] = $result->getMessage();
$this->debug("change_document_type - cannot change type - " . $result->getMessage(), $session_id);
@@ -2722,10 +2603,8 @@ class KTWebService
{
return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $kt);
}
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_DOCUMENT,
- 'message'=>''
- );
+
+ $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT);
$document = &$kt->get_document_by_id($document_id);
if (PEAR::isError($document))
@@ -2780,10 +2659,8 @@ class KTWebService
{
return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $kt);
}
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_DOCUMENT,
- 'message'=>''
- );
+
+ $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT);
$document = &$kt->get_document_by_id($document_id);
if (PEAR::isError($document))
@@ -2837,10 +2714,8 @@ class KTWebService
{
return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $kt);
}
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_DOCUMENT,
- 'message'=>''
- );
+
+ $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT);
$document = &$kt->get_document_by_id($document_id);
if (PEAR::isError($document))
@@ -2890,10 +2765,8 @@ class KTWebService
{
return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $kt);
}
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_DOCUMENT,
- 'message'=>''
- );
+
+ $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT);
$document = &$kt->get_document_by_id($document_id);
if (PEAR::isError($document))
@@ -2916,7 +2789,6 @@ class KTWebService
return $this->get_document_detail($session_id, $document_id);
}
-
return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $response);
}
@@ -2946,10 +2818,7 @@ class KTWebService
return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $kt);
}
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_DOCUMENT,
- 'message'=>''
- );
+ $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT);
$document = &$kt->get_document_by_id($document_id);
if (PEAR::isError($document))
@@ -2999,10 +2868,8 @@ class KTWebService
{
return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $kt);
}
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_DOCUMENT,
- 'message'=>''
- );
+
+ $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT);
$document = &$kt->get_document_by_id($document_id);
if (PEAR::isError($document))
@@ -3049,10 +2916,8 @@ class KTWebService
{
return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $kt);
}
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_DOCUMENT,
- 'message'=>''
- );
+
+ $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT);
$document = &$kt->get_document_by_id($document_id);
if (PEAR::isError($document))
@@ -3102,10 +2967,8 @@ class KTWebService
{
return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $kt);
}
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_DOCUMENT,
- 'message'=>''
- );
+
+ $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT);
$document = &$kt->get_document_by_id($document_id);
if (PEAR::isError($document))
@@ -3133,100 +2996,41 @@ class KTWebService
}
/**
- * Encodes the array as a kt_metadata_selection_item
- *
- * @param aray $item
- * @param string $name
- * @return SOAP_Value of kt_metadata_selection_item
- * @access private
- * @static
- */
- function _encode_metadata_selection_item($item, $name='item')
- {
- if (!is_null($item['id']))
- {
- $item['id'] = (int) $item['id'];
- }
-
- if (!is_null($item['parent_id']))
- {
- $item['parent_id'] = (int) $item['parent_id'];
- }
-
- return new SOAP_Value($name,"{urn:$this->namespace}kt_metadata_selection_item", $item);
- }
-
- /**
- * Encode an array as kt_metadata_selection
+ * Encode an array as kt_metadata_fields
*
- * @param array $selection
+ * @param array $fields
* @param string $name
- * @return SOAP_Value of kt_metadata_selection
+ * @return SOAP_Value of kt_metadata_fields
* @access private
* @static
*/
-
- function _encode_metadata_selection($selection, $name='selection')
+ function _encode_metadata_fields($fields)
{
- $encoded=array();
- foreach($selection as $field)
- {
- $encoded[] = KTWebService::_encode_metadata_selection_item($field);
- }
-
- if (empty($encoded))
+ foreach($fields as $key=>$field)
{
- $encoded=null;
- }
+ $selection = $field['selection'];
+ foreach($selection as $skey=>$sitem)
+ {
+ if (!is_null($item['id']))
+ {
+ $sitem['id'] = (int) $sitem['id'];
+ }
+
+ if (!is_null($sitem['parent_id']))
+ {
+ $sitem['parent_id'] = (int) $sitem['parent_id'];
+ }
+ $selection[$skey] = new SOAP_Value('item',"{urn:$this->namespace}kt_metadata_selection_item", $sitem);
+ }
- return new SOAP_Value($name,"{urn:$this->namespace}kt_metadata_selection", $encoded);
- }
+ $field['selection'] = new SOAP_Value('selection',"{urn:$this->namespace}kt_metadata_selection", $selection);
- /**
- * Encode an array as kt_metadata_field
- *
- * @param arra $field
- * @param string $name
- * @return SOAP_Value of kt_metadata_field
- * @access private
- * @static
- */
+ $field['required'] = is_null($field['required'])?false:(bool) $field['required'];
- function _encode_metadata_field($field, $name='field')
- {
- if (!empty($field['selection']))
- {
- $field['selection'] = KTWebService::_encode_metadata_selection($field['selection']);
- }
- if (!is_null($field['required']))
- {
- $field['required'] = (bool) $field['required'];
+ $fields[$key] = new SOAP_Value('field',"{urn:$this->namespace}kt_metadata_field", $field);
}
- return new SOAP_Value($name,"{urn:$this->namespace}kt_metadata_field", $field);
- }
-
- /**
- * Encode an array as kt_metadata_fields
- *
- * @param array $fields
- * @param string $name
- * @return SOAP_Value of kt_metadata_fields
- * @access private
- * @static
- */
- function _encode_metadata_fields($fields, $name='fields')
- {
- $encoded=array();
- foreach($fields as $field)
- {
- $encoded[] = KTWebService::_encode_metadata_field($field);
- }
- if (empty($encoded))
- {
- $encoded=null;
- }
- return new SOAP_Value($name,"{urn:$this->namespace}kt_metadata_fields", $encoded);
+ return new SOAP_Value('fields',"{urn:$this->namespace}kt_metadata_fields", $fields);
}
/**
@@ -3291,7 +3095,6 @@ class KTWebService
}
return new SOAP_Value($name,"{urn:$this->namespace}kt_metadata_response", $response);
-
}
/**
@@ -3301,7 +3104,6 @@ class KTWebService
* @param string $document_type
* @return kt_metadata_response
*/
-
function get_document_type_metadata($session_id, $document_type)
{
$this->debug("get_document_type_metadata('$session_id','$document_type')");
@@ -3310,10 +3112,8 @@ class KTWebService
{
return new SOAP_Value('return',"{urn:$this->namespace}kt_metadata_response", $kt);
}
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_DOCUMENT,
- 'message'=>''
- );
+
+ $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT);
$metadata = $kt->get_document_type_metadata($document_type);
if (PEAR::isError($metadata))
@@ -3370,10 +3170,8 @@ class KTWebService
{
return new SOAP_Value('return',"{urn:$this->namespace}kt_metadata_response", $kt);
}
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_DOCUMENT,
- 'message'=>''
- );
+
+ $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT);
$document = &$kt->get_document_by_id($document_id);
if (PEAR::isError($document))
@@ -3438,10 +3236,8 @@ class KTWebService
{
return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $kt);
}
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_DOCUMENT,
- 'message'=>''
- );
+
+ $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT);
$document = &$kt->get_document_by_id($document_id);
if (PEAR::isError($document))
@@ -3459,7 +3255,6 @@ class KTWebService
return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $response);
}
-
if ($this->version >= 2)
{
$result = $document->update_sysdata($sysdata);
@@ -3470,13 +3265,11 @@ class KTWebService
return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $response);
}
-
return $this->get_document_detail($session_id, $document_id, 'M');
}
$response['status_code'] = KTWS_SUCCESS;
return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $response);
-
}
/**
@@ -3494,10 +3287,7 @@ class KTWebService
{
return new SOAP_Value('return',"{urn:$this->namespace}kt_workflow_transitions_response", $kt);
}
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_DOCUMENT,
- 'message'=>''
- );
+ $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT);
$document = &$kt->get_document_by_id($document_id);
if (PEAR::isError($document))
@@ -3517,11 +3307,16 @@ class KTWebService
}
$response['status_code'] = KTWS_SUCCESS;
- $response['transitions'] = $result;
+ $response['transitions'] = KTWebService::_encode_document_workflow_transitions($result);
return new SOAP_Value('return',"{urn:$this->namespace}kt_workflow_transitions_response", $response);
}
+ function _encode_document_workflow_transitions($transitions, $name='transitions')
+ {
+ return new SOAP_Value($name,"{urn:$this->namespace}kt_workflow_transitions", $transitions);
+ }
+
/**
* Returns the current state that the document is in.
*
@@ -3538,10 +3333,7 @@ class KTWebService
{
return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $kt);
}
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_DOCUMENT,
- 'message'=>''
- );
+ $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT);
$document = &$kt->get_document_by_id($document_id);
if (PEAR::isError($document))
@@ -3567,20 +3359,6 @@ class KTWebService
}
/**
- * Encode an array as kt_document_transaction_history_item
- *
- * @param array $item
- * @param string $name
- * @return SOAP_Value of kt_document_transaction_history_item
- * @access private
- * @static
- */
- function _encode_transaction_history_item($item, $name='item')
- {
- return new SOAP_Value($name,"{urn:$this->namespace}kt_document_transaction_history_item", $item);
- }
-
- /**
* Encode an array as kt_document_transaction_history
*
* @param array $history
@@ -3591,29 +3369,11 @@ class KTWebService
*/
function _encode_transaction_history($history, $name='history')
{
- $encoded=array();
- foreach($history as $item)
+ foreach($history as $key=>$item)
{
- $encoded[] = KTWebService::_encode_transaction_history_item($item);
+ $history[$key] = new SOAP_Value('item',"{urn:$this->namespace}kt_document_transaction_history_item", $item);
}
-
- return new SOAP_Value($name,"{urn:$this->namespace}kt_document_transaction_history", $encoded);
- }
-
- /**
- * Encode an array as kt_document_transaction_history_response
- *
- * @param array $response
- * @param string $name
- * @return SOAP_Value of kt_document_transaction_history_response
- * @access private
- * @static
- */
- function _encode_transaction_history_response($response, $name='return')
- {
- $response['history'] = KTWebService::_encode_transaction_history($response['history']);
-
- return new SOAP_Value($name,"{urn:$this->namespace}kt_document_transaction_history_response", $response);
+ return new SOAP_Value($name,"{urn:$this->namespace}kt_document_transaction_history", $history);
}
/**
@@ -3631,10 +3391,7 @@ class KTWebService
{
return new SOAP_Value('return',"{urn:$this->namespace}kt_document_transaction_history_response", $kt);
}
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_DOCUMENT,
- 'message'=>''
- );
+ $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT);
$document = &$kt->get_document_by_id($document_id);
if (PEAR::isError($document))
@@ -3654,23 +3411,9 @@ class KTWebService
}
$response['status_code'] = KTWS_SUCCESS;
- $response['history'] = $result;
+ $response['history'] = KTWebService::_encode_transaction_history($result);
- return KTWebService::_encode_transaction_history_response($response);
- }
-
- /**
- * Encode an array as kt_document_version_history_item
- *
- * @param array $item
- * @param string $name
- * @return SOAP_Value of kt_document_version_history_item
- * @access private
- * @static
- */
- function _encode_version_history_item($item, $name='item')
- {
- return new SOAP_Value($name,"{urn:$this->namespace}kt_document_version_history_item", $item);
+ return new SOAP_Value('return',"{urn:$this->namespace}kt_document_transaction_history_response", $response);
}
/**
@@ -3684,32 +3427,13 @@ class KTWebService
*/
function _encode_version_history($history, $name='history')
{
- $encoded=array();
- foreach($history as $item)
+ foreach($history as $key=>$item)
{
- $encoded[] = KTWebService::_encode_version_history_item($item);
+ $history[$key] = new SOAP_Value('item',"{urn:$this->namespace}kt_document_version_history_item", $item);
}
-
- return new SOAP_Value($name,"{urn:$this->namespace}kt_document_version_history", $encoded);
- }
-
- /**
- * Encode an array as kt_document_version_history_response
- *
- * @param array $response
- * @param string $name
- * @return SOAP_Value of kt_document_version_history_response
- * @access private
- * @static
- */
- function _encode_version_history_response($response, $name='return')
- {
- $response['history'] = KTWebService::_encode_version_history($response['history']);
-
- return new SOAP_Value($name,"{urn:$this->namespace}kt_document_version_history_response", $response);
+ return new SOAP_Value($name,"{urn:$this->namespace}kt_document_version_history", $history);
}
-
/**
* Returns the version history.
*
@@ -3726,10 +3450,7 @@ class KTWebService
{
return new SOAP_Value('return',"{urn:$this->namespace}kt_document_version_history_response", $kt);
}
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_DOCUMENT,
- 'message'=>''
- );
+ $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT);
$document = &$kt->get_document_by_id($document_id);
if (PEAR::isError($document))
@@ -3749,12 +3470,11 @@ class KTWebService
}
$response['status_code'] = KTWS_SUCCESS;
- $response['history'] = $result;
+ $response['history'] =KTWebService::_encode_version_history($result);
- return KTWebService::_encode_version_history_response($response);
+ return new SOAP_Value('return',"{urn:$this->namespace}kt_document_version_history_response", $response);
}
-
/**
* Returns a list of linked documents
*
@@ -3789,12 +3509,25 @@ class KTWebService
}
$links = $document->get_linked_documents();
- $response['links'] = new SOAP_Value('links',"{urn:$this->namespace}kt_linked_documents", $links);
+ $response['links'] = KTWebService::_encode_document_links($links);
$response['status_code'] = KTWS_SUCCESS;
return new SOAP_Value('return',"{urn:$this->namespace}kt_linked_document_response", $response);
}
+ function _encode_document_links($links, $name='links')
+ {
+ foreach($links as $key=>$link)
+ {
+ $link['document_id'] = (int) $link['document_id'];
+ $link['filesize'] = (int) $link['filesize'];
+
+ $links[$key] = new SOAP_Value('links',"{urn:$this->namespace}kt_linked_document", $link);
+ }
+
+ return new SOAP_Value($name,"{urn:$this->namespace}kt_linked_documents", $links);
+ }
+
/**
* Removes a link between documents
*
@@ -3812,10 +3545,7 @@ class KTWebService
{
return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $kt);
}
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_DOCUMENT,
- 'message'=>''
- );
+ $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT);
$document = &$kt->get_document_by_id($parent_document_id);
if (PEAR::isError($document))
@@ -3864,10 +3594,7 @@ class KTWebService
{
return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $kt);
}
- $response=array(
- 'status_code'=>KTWS_ERR_INVALID_DOCUMENT,
- 'message'=>''
- );
+ $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT);
$document = &$kt->get_document_by_id($parent_document_id);
if (PEAR::isError($document))
@@ -3899,17 +3626,13 @@ class KTWebService
}
function _encode_client_policies($policies)
- {
- $encoded=array();
- foreach($policies as $policy)
- {
- $encoded[] = new SOAP_Value('policy',"{urn:$this->namespace}kt_client_policy", $policy);
- }
- if (empty($encoded))
+ {
+ foreach($policies as $key=>$policy)
{
- $encoded=null;
+ $policies[$key] = new SOAP_Value('policy',"{urn:$this->namespace}kt_client_policy", $policy);
}
- return new SOAP_Value('policies',"{urn:$this->namespace}kt_client_policies_array", $encoded);
+
+ return new SOAP_Value('policies',"{urn:$this->namespace}kt_client_policies_array", $policies);
}
/**
@@ -3918,7 +3641,7 @@ class KTWebService
* @param string $session_id
* @return kt_client_policies_response
*/
- function get_client_policies($session_id)
+ function get_client_policies($session_id, $client=null)
{
$this->debug("get_client_policies('$session_id')");
$config = KTConfig::getSingleton();
@@ -3964,9 +3687,13 @@ class KTWebService
'value' => bool2str($config->get('clientToolPolicies/captureReasonsMoveInKT')),
'type' => 'boolean'
),
+ array(
+ 'name' => 'allow_remember_password',
+ 'value' => bool2str($config->get('clientToolPolicies/allowRememberPassword')),
+ 'type' => 'boolean'
+ ),
);
-
$response['policies'] = $this->_encode_client_policies($policies);
$response['message'] = 'Knowledgetree client policies retrieval succeeded.';
$response['status_code'] = KTWS_SUCCESS;
@@ -3991,11 +3718,9 @@ class KTWebService
{
return new SOAP_Value('return',"{urn:$this->namespace}kt_search_response", $kt);
}
- $response=array(
- 'status_code'=>KTWS_ERR_PROBLEM,
- 'message'=>'',
- 'hits'=>array()
- );
+
+ $response = KTWebService::_status(KTWS_ERR_PROBLEM);
+ $response['hits'] = array();
if (!defined('HAS_SEARCH_FUNCTIONALITY'))
{
@@ -4024,7 +3749,6 @@ class KTWebService
return new SOAP_Value('return',"{urn:$this->namespace}kt_search_response", $response);
}
-
/**
* The main json request processing function.
*
@@ -4186,8 +3910,7 @@ class KTWebService
}
-
-$webservice = new KTWebService();
+$webservice = KTWebService::get();
$webservice->run();
-?>
+?>
\ No newline at end of file
diff --git a/lib/browse/DocumentCollection.inc.php b/lib/browse/DocumentCollection.inc.php
index 1dcacd0..94c9331 100644
--- a/lib/browse/DocumentCollection.inc.php
+++ b/lib/browse/DocumentCollection.inc.php
@@ -5,32 +5,32 @@
* KnowledgeTree Open Source Edition
* Document Management Made Simple
* Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited
- *
+ *
* 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 The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
* Blake Street, Observatory, 7925 South Africa. 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
- * copyright notice.
+ * must display the words "Powered by KnowledgeTree" and retain the original
+ * copyright notice.
* Contributor( s): ______________________________________
*
*/
@@ -618,4 +618,54 @@ class AdvancedCollection {
}
}
-?>
+class ExtCollection {
+
+ var $columns;
+ var $folders;
+ var $documents;
+
+ /**
+ * Add the column headers
+ *
+ * @param array $aColumns
+ */
+ function addColumns($aColumns) {
+ $this->columns = $aColumns;
+ }
+
+ /**
+ * Add the folders under the folder
+ *
+ * @param array $aFolders
+ */
+ function addFolders($aFolders) {
+ $this->folders = $aFolders;
+ }
+
+ /**
+ * Add the documents contained in the folder
+ *
+ * @param array $aDocuments
+ */
+ function addDocuments($aDocuments) {
+ $this->documents = $aDocuments;
+ }
+
+ function render() {
+
+ global $main;
+ $main->requireJSResource('thirdpartyjs/extjs/adapter/ext/ext-base.js');
+ $main->requireJSResource('thirdpartyjs/extjs/ext-all.js');
+ $main->requireJSResource('resources/js/browse_ext.js');
+
+ $oTemplating =& KTTemplating::getSingleton();
+ $oTemplate = $oTemplating->loadTemplate('kt3/ext_collection');
+ $aTemplateData = array(
+ );
+
+ // in order to allow OTHER things than batch to move us around, we do:
+ return $oTemplate->render($aTemplateData);
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/lib/cache/cache.inc.php b/lib/cache/cache.inc.php
index 492bdaa..8d48ff5 100644
--- a/lib/cache/cache.inc.php
+++ b/lib/cache/cache.inc.php
@@ -5,32 +5,32 @@
* KnowledgeTree Open Source Edition
* Document Management Made Simple
* Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited
- *
+ *
* 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 The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
* Blake Street, Observatory, 7925 South Africa. 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
- * copyright notice.
+ * must display the words "Powered by KnowledgeTree" and retain the original
+ * copyright notice.
* Contributor( s): ______________________________________
*/
@@ -75,9 +75,14 @@ class KTCache {
if (!file_exists($aOptions['cacheDir'])) {
mkdir($aOptions['cacheDir']);
}
+
+ // See thirdparty/pear/Cache/Lite.php to customize cache
$aOptions['lifeTime'] = 60;
$aOptions['memoryCaching'] = true;
$aOptions['automaticSerialization'] = true;
+ /* Patched line */
+ // Disable fileCaching (when cache > 5Mo)
+ $aOptions['onlyMemoryCaching'] = true;
$this->cacheDir = $aOptions['cacheDir'];
diff --git a/lib/dispatcher.inc.php b/lib/dispatcher.inc.php
index 0c7f34e..dd8aa19 100644
--- a/lib/dispatcher.inc.php
+++ b/lib/dispatcher.inc.php
@@ -538,6 +538,39 @@ class KTErrorDispatcher extends KTStandardDispatcher {
function dispatch() {
require_once(KT_LIB_DIR . '/validation/errorviewer.inc.php');
+ require_once(KT_LIB_DIR . '/validation/customerrorviewer.inc.php');
+
+ $oCustomViewer =& KTCustomErrorViewer::initCustomErrorViewer();
+
+ //if the custom error messages are set to 'on' in the config file
+ //we check if the error page exists and redirect to it if it does.
+ //if either the page doesn't exit or the custom error option is off in the config file
+ //we carry out default error reporting
+ if ($oCustomViewer->getCustomErrorConfigSetting() == 'on'){
+ $CustomErrorPage = $oCustomViewer->getCustomErrorRedirectPage();
+ if ( $CustomErrorPage != '0') //if an error is not returned from getCustomErrorRedirectPage();
+ {
+ $sErrorHandler = $oCustomViewer->getCustomErrorHandlerSetting();
+
+ //redirect
+ if ($sErrorHandler == 'on')
+ {
+ //if custom error handler is set to on inside config.ini then send error object with error page
+ $oCustomViewer->doCustomErrorPageRedirect($CustomErrorPage, $this->oError);
+ }
+ else if ($sErrorHandler != 'on')
+ {
+ //if custom error handler is set to off inside config.ini then just send error page
+ $oCustomViewer->doCustomErrorPageRedirect($CustomErrorPage);
+ }
+
+ //exit without errors
+ exit(0);
+ }
+ }
+
+ //if either customer error messages is off or the custom error page doesn't exist the function will run
+ //the default error handling here
$oRegistry =& KTErrorViewerRegistry::getSingleton();
$oViewer =& $oRegistry->getViewer($this->oError);
$this->oPage->setTitle($oViewer->view());
diff --git a/lib/documentmanagement/DocumentFieldLink.inc b/lib/documentmanagement/DocumentFieldLink.inc
index 0b82d80..e5833ce 100644
--- a/lib/documentmanagement/DocumentFieldLink.inc
+++ b/lib/documentmanagement/DocumentFieldLink.inc
@@ -7,39 +7,39 @@
* KnowledgeTree Open Source Edition
* Document Management Made Simple
* Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited
- *
+ *
* 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 The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
* Blake Street, Observatory, 7925 South Africa. 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
- * copyright notice.
+ * must display the words "Powered by KnowledgeTree" and retain the original
+ * copyright notice.
* Contributor( s): ______________________________________
*/
require_once(KT_LIB_DIR . "/util/sanitize.inc");
class DocumentFieldLink extends KTEntity {
-
+
/** document field link primary key */
var $iId;
/** primary key of document to which field is linked */
@@ -55,9 +55,9 @@ class DocumentFieldLink extends KTEntity {
'iDocumentFieldId' => 'document_field_id',
'sValue' => 'value',
);
-
+
/**
- * Default constructor
+ * Default constructor
*
* @param Primary key of document to which field is linked
* @param Primary key of field to which document is linked
@@ -71,7 +71,7 @@ class DocumentFieldLink extends KTEntity {
$this->iDocumentFieldId = $iNewDocumentFieldId;
$this->sValue = $sNewValue;
}
-
+
/**
* Get the document field link primary key
*
@@ -81,7 +81,7 @@ class DocumentFieldLink extends KTEntity {
function getId() {
return $this->iId;
}
-
+
/**
* Get the primary key of the document to which the field is linked
*
@@ -91,7 +91,7 @@ class DocumentFieldLink extends KTEntity {
function getMetadataVersionId() {
return $this->iMetadataVersionId;
}
-
+
/**
* Set the primary key of the document to which the field is linked
*
@@ -101,7 +101,7 @@ class DocumentFieldLink extends KTEntity {
function setMetadataVersionId($iNewValue) {
$this->iMetadataVersionId = $iNewValue;
}
-
+
/**
* Get the primary key of the field to which the document is linked
*
@@ -111,7 +111,7 @@ class DocumentFieldLink extends KTEntity {
function getDocumentFieldId() {
return $this->iDocumentFieldId;
}
-
+
/**
* Set the primary key of the field to which the document is related
*
@@ -121,7 +121,7 @@ class DocumentFieldLink extends KTEntity {
function setDocumentFieldId($iNewVale) {
$this->iDocumentFieldId = $iNewValue;
}
-
+
/**
* Get the value of the field
*
@@ -129,9 +129,9 @@ class DocumentFieldLink extends KTEntity {
*
*/
function getValue() {
- return sanitizeForSQLtoHTML($this->sValue);
+ return $this->sValue;
}
-
+
/**
* Set the value of the field
*
@@ -145,7 +145,7 @@ class DocumentFieldLink extends KTEntity {
function _table () {
return KTUtil::getTableName('document_fields_link');
}
-
+
/**
*
* Static function. Given a document fields link primary key will create
diff --git a/lib/documentmanagement/documentcore.inc.php b/lib/documentmanagement/documentcore.inc.php
index 0e36138..9fea43d 100644
--- a/lib/documentmanagement/documentcore.inc.php
+++ b/lib/documentmanagement/documentcore.inc.php
@@ -5,32 +5,32 @@
* KnowledgeTree Open Source Edition
* Document Management Made Simple
* Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited
- *
+ *
* 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 The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
* Blake Street, Observatory, 7925 South Africa. 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
- * copyright notice.
+ * must display the words "Powered by KnowledgeTree" and retain the original
+ * copyright notice.
* Contributor( s): ______________________________________
*
*/
@@ -181,13 +181,16 @@ class KTDocumentCore extends KTEntity {
// {{{ ktentity requirements
function _fieldValues () {
- $sNewFullPath = Folder::generateFolderPath($this->iFolderId);
- if (!PEAR::isError($sNewFullPath)) {
- $this->sFullPath = $sNewFullPath;
- }
- $sNewParentFolderIds = Folder::generateFolderIds($this->iFolderId);
- if (!PEAR::isError($sNewParentFolderIds)) {
- $this->sParentFolderIds = $sNewParentFolderIds;
+ static $lastFolder = null;
+ if (is_null($lastFolder) || $lastFolder->getID() !== $this->iFolderId) {
+ $lastFolder = Folder::get($this->iFolderId);
+ if (PEAR::isError($lastFolder)) {
+ $lastFolder = null;
+ }
+ }
+ if (!is_null($lastFolder)) {
+ $this->sFullPath = $lastFolder->getFullPath();
+ $this->sParentFolderIds = $lastFolder->getParentFolderIDs();
}
return parent::_fieldValues();
}
@@ -256,6 +259,9 @@ class KTDocumentCore extends KTEntity {
$this->bImmutable = false;
}
$oFolder = Folder::get($this->getFolderId());
+ if (PEAR::isError($oFolder) || ($oFolder === false) || empty($oFolder) ) {
+ return false;
+ }
$this->iPermissionObjectId = $oFolder->getPermissionObjectId();
$res = parent::create();
diff --git a/lib/documentmanagement/documentutil.inc.php b/lib/documentmanagement/documentutil.inc.php
index 0a83968..8378639 100644
--- a/lib/documentmanagement/documentutil.inc.php
+++ b/lib/documentmanagement/documentutil.inc.php
@@ -561,7 +561,9 @@ class KTDocumentUtil {
$oUploadChannel =& KTUploadChannel::getSingleton();
$oUploadChannel->sendMessage(new KTUploadNewFile($sFilename));
+ DBUtil::startTransaction();
$oDocument =& KTDocumentUtil::_add($oFolder, $sFilename, $oUser, $aOptions);
+
// $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt('Document created')));
if (PEAR::isError($oDocument)) {
return $oDocument;
@@ -633,6 +635,7 @@ class KTDocumentUtil {
}
KTDocumentUtil::updateSearchableText($oDocument, true);
+ DBUtil::commit();
$oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt('All done...')));
return $oDocument;
@@ -718,7 +721,7 @@ class KTDocumentUtil {
$iMimeTypeId = KTMime::getMimeTypeID($sType, $oDocument->getFileName());
$oDocument->setMimeTypeId($iMimeTypeId);
- $res = $oStorage->upload($oDocument, $sFilename);
+ $res = $oStorage->upload($oDocument, $sFilename, $aOptions);
if ($res === false) {
return PEAR::raiseError(sprintf(_kt("Couldn't store contents: %s"), _kt('No reason given')));
}
@@ -727,7 +730,7 @@ class KTDocumentUtil {
}
KTDocumentUtil::setComplete($oDocument, 'contents');
- if ($aOptions['cleanup_initial_file']) {
+ if ($aOptions['cleanup_initial_file'] && file_exists($sFilename)) {
@unlink($sFilename);
}
diff --git a/lib/foldermanagement/Folder.inc b/lib/foldermanagement/Folder.inc
index 23144a6..7d53bd6 100644
--- a/lib/foldermanagement/Folder.inc
+++ b/lib/foldermanagement/Folder.inc
@@ -7,32 +7,32 @@
* KnowledgeTree Open Source Edition
* Document Management Made Simple
* Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited
- *
+ *
* 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 The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
* Blake Street, Observatory, 7925 South Africa. 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
- * copyright notice.
+ * must display the words "Powered by KnowledgeTree" and retain the original
+ * copyright notice.
* Contributor( s): ______________________________________
*/
@@ -82,10 +82,10 @@ class Folder extends KTEntity {
// }}}
function getID() { return $this->iId; }
- function getName() { return sanitizeForSQLtoHTML($this->sName); }
- function setName($sNewValue) { $this->sName = sanitizeForSQL($sNewValue); }
- function getDescription() { return sanitizeForSQLtoHTML($this->sDescription); }
- function setDescription($sNewValue) { $this->sDescription = sanitizeForSQL($sNewValue); }
+ function getName() { return ($this->sName); }
+ function setName($sNewValue) { $this->sName = ($sNewValue); }
+ function getDescription() { return ($this->sDescription); }
+ function setDescription($sNewValue) { $this->sDescription = ($sNewValue); }
function getParentID() { return $this->iParentID; }
function setParentID($iNewValue) { $this->iParentID = $iNewValue; }
function getCreatorID() { return $this->iCreatorID; }
diff --git a/lib/foldermanagement/compressionArchiveUtil.inc.php b/lib/foldermanagement/compressionArchiveUtil.inc.php
index e90c7f2..353df40 100644
--- a/lib/foldermanagement/compressionArchiveUtil.inc.php
+++ b/lib/foldermanagement/compressionArchiveUtil.inc.php
@@ -5,32 +5,32 @@
* KnowledgeTree Open Source Edition
* Document Management Made Simple
* Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited
- *
+ *
* 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 The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
* Blake Street, Observatory, 7925 South Africa. 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
- * copyright notice.
+ * must display the words "Powered by KnowledgeTree" and retain the original
+ * copyright notice.
* Contributor( s): ______________________________________
*
*/
@@ -79,10 +79,17 @@ class ZipFolder {
/**
* Add a document to the zip file
*/
- function addDocumentToZip($oDocument) {
- $sParentFolder = str_replace('<', '', str_replace('', '', str_replace('>', '', sprintf('%s/%s', $this->sTmpPath, $oDocument->getFullPath()))));
+ function addDocumentToZip($oDocument, $oFolder = null) {
+ if(empty($oFolder)){
+ $oFolder = Folder::get($oDocument->getFolderID());
+ }
+
+ $sDocPath = $oFolder->getFullPath().'/'.$oFolder->getName();
+ $sDocName = $oDocument->getFileName();
+
+ $sParentFolder = str_replace('<', '', str_replace('', '', str_replace('>', '', sprintf('%s/%s', $this->sTmpPath, $sDocPath))));
$newDir = $this->sTmpPath;
- $sFullPath = str_replace('<', '', str_replace('', '', str_replace('>', '', $this->_convertEncoding($oDocument->getFullPath(), true))));
+ $sFullPath = str_replace('<', '', str_replace('', '', str_replace('>', '', $this->_convertEncoding($sDocPath, true))));
foreach (split('/', $sFullPath) as $dirPart) {
$newDir = sprintf("%s/%s", $newDir, $dirPart);
if (!file_exists($newDir)) {
@@ -91,11 +98,11 @@ class ZipFolder {
}
$sOrigFile = str_replace('<', '', str_replace('', '', str_replace('>', '', $this->oStorage->temporaryFile($oDocument))));
- $sFilename = sprintf("%s/%s", $sParentFolder, str_replace('<', '', str_replace('', '', str_replace('>', '', $oDocument->getFileName()))));
+ $sFilename = sprintf("%s/%s", $sParentFolder, str_replace('<', '', str_replace('', '', str_replace('>', '', $sDocName))));
$sFilename = $this->_convertEncoding($sFilename, true);
copy($sOrigFile, $sFilename);
- $sPath = str_replace('<', '', str_replace('', '', str_replace('>', '', sprintf("%s/%s", $oDocument->getFullPath(), $oDocument->getFileName()))));
+ $sPath = str_replace('<', '', str_replace('', '', str_replace('>', '', sprintf("%s/%s", $sDocPath, $sDocName))));
$sPath = str_replace($this->aReplaceKeys, $this->aReplaceValues, $sPath);
$sPath = $this->_convertEncoding($sPath, true);
diff --git a/lib/foldermanagement/folderutil.inc.php b/lib/foldermanagement/folderutil.inc.php
index fab0137..dc5ad98 100644
--- a/lib/foldermanagement/folderutil.inc.php
+++ b/lib/foldermanagement/folderutil.inc.php
@@ -57,8 +57,8 @@ class KTFolderUtil {
}
$oStorage =& KTStorageManagerUtil::getSingleton();
$oFolder =& Folder::createFromArray(array(
- 'name' => sanitizeForSQL($sFolderName),
- 'description' => sanitizeForSQL($sFolderName),
+ 'name' => ($sFolderName),
+ 'description' => ($sFolderName),
'parentid' => $oParentFolder->getID(),
'creatorid' => $oUser->getID(),
));
diff --git a/lib/import/bulkimport.inc.php b/lib/import/bulkimport.inc.php
index 1994507..d92020d 100644
--- a/lib/import/bulkimport.inc.php
+++ b/lib/import/bulkimport.inc.php
@@ -7,32 +7,32 @@
* KnowledgeTree Open Source Edition
* Document Management Made Simple
* Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited
- *
+ *
* 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 The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
* Blake Street, Observatory, 7925 South Africa. 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
- * copyright notice.
+ * must display the words "Powered by KnowledgeTree" and retain the original
+ * copyright notice.
* Contributor( s): ______________________________________
*/
@@ -72,7 +72,7 @@ class KTBulkImportManager {
function _importfolder($oFolder, $sPath) {
$oPermission = KTPermission::getByName('ktcore.permissions.addFolder');
-
+
$aDocPaths = $this->oStorage->listDocuments($sPath);
if (PEAR::isError($aDocPaths)) {
return $aDocPaths;
@@ -91,7 +91,7 @@ class KTBulkImportManager {
if (Folder::folderExistsName(utf8_encode(basename($sFolderPath)), KTUtil::getId($oFolder))) {
$_SESSION['KTErrorMessage'][] = sprintf(_kt("The folder %s is already present in %s. Adding files into pre-existing folder."), utf8_encode(basename($sFolderPath)), $oFolder->getName());
$aOptions = Folder::getList("parent_id = " . KTUtil::getId($oFolder) . ' AND name = "' . DBUtil::escapeSimple(utf8_encode(basename($sFolderPath))) . '"');
- if (PEAR::isError($aOptions)) {
+ if (PEAR::isError($aOptions)) {
return $aOptions;
}
if (count($aOptions) != 1) {
@@ -100,7 +100,7 @@ class KTBulkImportManager {
$oThisFolder = $aOptions[0];
}
} else {
-
+
if(KTPermissionUtil::userHasPermissionOnItem($this->oUser, $oPermission, $oFolder))
{
$oThisFolder = KTFolderUtil::add($oFolder, utf8_encode(basename($sFolderPath)), $this->oUser);
@@ -119,7 +119,7 @@ class KTBulkImportManager {
}
$res = $this->_importfolder($oThisFolder, $sFolderPath);
-
+
if (PEAR::isError($res)) {
return $res;
}
@@ -128,6 +128,7 @@ class KTBulkImportManager {
function _importdocument($oFolder, $sPath) {
$aInfo = $this->oStorage->getDocumentInfo($sPath);
+ $sTmpFileName = sprintf("%s/%s", $this->oStorage->sBasePath, $sPath);
if (PEAR::isError($aInfo)) {
return $aInfo;
}
@@ -135,7 +136,7 @@ class KTBulkImportManager {
/*if (KTDocumentUtil::nameExists($oFolder, utf8_encode(basename($sPath)))) {
$_SESSION['KTErrorMessage'][] = sprintf(_kt("The document %s is already present in %s. Ignoring."), utf8_encode(basename($sPath)), $oFolder->getName());
$oDocument =& Document::getByNameAndFolder(utf8_encode(basename($sPath)), KTUtil::getId($oFolder));
- return $oDocument;
+ return $oDocument;
} else if (KTDocumentUtil::fileExists($oFolder, utf8_encode(basename($sPath)))) {
$_SESSION['KTErrorMessage'][] = sprintf(_kt("The document %s is already present in %s. Ignoring."), utf8_encode(basename($sPath)), $oFolder->getName());
$oDocument =& Document::getByFilenameAndFolder(utf8_encode(basename($sPath)), KTUtil::getId($oFolder));
@@ -144,10 +145,12 @@ class KTBulkImportManager {
// else
$aOptions = array(
// XXX: Multiversion Import
- 'contents' => $aInfo->aVersions[0],
+ //'contents' => $aInfo->aVersions[0],
+ 'temp_file' => $sTmpFileName,
'metadata' => $this->aMetadata,
'documenttype' => $this->oDocumentType,
);
+ $aOptions = array_merge($aOptions, $this->aOptions);
$oDocument =& KTDocumentUtil::add($oFolder, utf8_encode(basename($sPath)), $this->oUser, $aOptions);
return $oDocument;
}
diff --git a/lib/ktentity.inc b/lib/ktentity.inc
index ed819a9..840d9cc 100644
--- a/lib/ktentity.inc
+++ b/lib/ktentity.inc
@@ -7,32 +7,32 @@
* KnowledgeTree Open Source Edition
* Document Management Made Simple
* Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited
- *
+ *
* 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 The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
* Blake Street, Observatory, 7925 South Africa. 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
- * copyright notice.
+ * must display the words "Powered by KnowledgeTree" and retain the original
+ * copyright notice.
* Contributor( s): ______________________________________
*/
@@ -742,58 +742,65 @@ class KTEntityUtil {
// var_dump("Building proxy for $sClassName");
$methods = get_class_methods($sClassName);
$allcode = array();
+ $allcode[] = sprintf('var $cacheGlobal = null;%s', "\n");
+
foreach ($methods as $sMethod) {
- $code = sprintf('function %s() { $aArgs = func_get_args(); return $this->_callOnObject("%s", $aArgs); }%s', $sMethod, $sMethod, "\n");
- $allcode[] = $code;
+ if ($sMethod == 'getid') {
+ $code = sprintf('function getId() { return $this->iId; }');
+ } else if ($sMethod == '_table' || $sMethod == 'update' ) {
+ $code = sprintf('function %s() { return parent::%s(); }', $sMethod, $sMethod);
+ } else if ($sMethod == 'get') {
+ $code = sprintf('function get($oId) { return $this->get(%s, $oid); }', $sClassName);
+ } else {
+ $code = sprintf('function %s() { $aArgs = func_get_args(); return $this->_callOnObject("%s", $aArgs); }%s', $sMethod, $sMethod, "\n");
+ }
+ $allcode[] = $code;
}
$allcode[] = sprintf('function &_fetch() {
- if (!empty($GLOBALS["_OBJECTCACHE"]["%s"][$this->iId])) {
- $oObject =& $GLOBALS["_OBJECTCACHE"]["%s"][$this->iId];
+ if (!empty($this->cacheGlobal[$this->iId])) {
+ $oObject =& $this->cacheGlobal[$this->iId];
+ return $oObject;
+ }
+ $oObject =new %s;
+ $res = $oObject->load($this->iId);
+ if (PEAR::isError($res)) {
+ return $res;
+ }
+ $this->cacheGlobal[$this->iId] =& $oObject;
return $oObject;
- }
- $oObject =new %s;
- $res = $oObject->load($this->iId);
- if (PEAR::isError($res)) {
- return $res;
- }
- $GLOBALS["_OBJECTCACHE"]["%s"][$this->iId] =& $oObject;
- return $oObject;
- }
- ', $sClassName, $sClassName, $sClassName, $sClassName);
+ }', $sClassName, $sClassName, $sClassName, $sClassName);
$allcode[] = sprintf('function _save(&$oObject) {
- $GLOBALS["_OBJECTCACHE"]["%s"][$this->iId] =& $oObject;
- }
- ', $sClassName);
+ $this->cacheGlobal[$this->iId] =& $oObject;
+ }', $sClassName);
$allcode[] = 'function &_callOnObject($sName, $aArgs) {
- $oObject =& $this->_fetch();
- if (PEAR::isError($oObject)) {
- return $oObject;
- }
- /* */
- $res = call_user_func_array(array(&$oObject, $sName), $aArgs);
- $this->_save($oObject);
- return $res;
- /* */
+ $oObject =& $this->_fetch();
+ if (PEAR::isError($oObject)) {
+ return $oObject;
+ }
+ /* */
+ $res = call_user_func_array(array(&$oObject, $sName), $aArgs);
+ $this->cacheGlobal[$this->iId] =& $oObject;
+ return $res;
+ /* */
- /* */
- $aExecArgs = array();
- $exec = \'$res =& $oObject->$sName(\';
- foreach (array_keys($aArgs) as $iKey) {
- $aExecArgs[] = \'$aArgs[\' . $iKey . \']\';
- }
- $exec .= join(", ", $aExecArgs);
- $exec .= \');\';
- eval($exec);
- $this->_save($oObject);
- return $res;
- /* */
- }
- ';
+ /* */
+ $aExecArgs = array();
+ $exec = \'$res =& $oObject->$sName(\';
+ foreach (array_keys($aArgs) as $iKey) {
+ $aExecArgs[] = \'$aArgs[\' . $iKey . \']\';
+ }
+ $exec .= join(", ", $aExecArgs);
+ $exec .= \');\';
+ eval($exec);
+ $this->cacheGlobal[$this->iId] =& $oObject;
+ return $res;
+ /* */
+ }';
- $allcode[] = sprintf('function %s ($iId) { $this->iId = $iId; }' . "\n", $sProxyClassName);
+ $allcode[] = sprintf('function %s ($iId) { $this->iId = $iId; $this->cacheGlobal =& $GLOBALS["_OBJECTCACHE"][%s]; }' . "\n", $sProxyClassName, $sClassName);
$gen = sprintf("class %s extends %s {\n", $sProxyClassName, $sClassName);
$gen .= " " . join("\n ", $allcode) . "\n";
diff --git a/lib/metadata/fieldsetregistry.inc.php b/lib/metadata/fieldsetregistry.inc.php
index 908b9e8..d1be152 100644
--- a/lib/metadata/fieldsetregistry.inc.php
+++ b/lib/metadata/fieldsetregistry.inc.php
@@ -1,40 +1,40 @@
.
- *
+ *
* You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
* Blake Street, Observatory, 7925 South Africa. 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
- * copyright notice.
+ * must display the words "Powered by KnowledgeTree" and retain the original
+ * copyright notice.
* Contributor( s): ______________________________________
*/
-/* fun with adaptors.
+/* fun with adaptors.
*
* Each fieldset type needs to handle
* - widget generation
@@ -44,23 +44,23 @@
* - fulltext generation
* - search widget/criteria
*
- * Very little of this is actually handled in this version. In fact, at the
- * moment the entire thing is faked. This is done to make add/edit a little
+ * Very little of this is actually handled in this version. In fact, at the
+ * moment the entire thing is faked. This is done to make add/edit a little
* more sane.
*
* In the long term, the "correct" approach here will be to make the actual
* KTFieldsetType a class, and to extend fieldset with a "config_array" and
- * "fieldset_type_namespace" params.
+ * "fieldset_type_namespace" params.
*
* Comments and suggestions on this are welcome.
*/
-
+
require_once(KT_LIB_DIR . "/widgets/widgetfactory.inc.php");
require_once(KT_LIB_DIR . "/validation/validatorfactory.inc.php");
class KTFieldsetRegistry {
var $fieldsettypes;
-
+
var $oVF;
var $oWF;
@@ -70,11 +70,11 @@ class KTFieldsetRegistry {
}
return $GLOBALS['_KT_PLUGIN']['oKTFieldsetRegistry'];
}
-
+
function registerType($sClassname, $sNS, $sFile) {
// stub
}
-
+
function formElementsForFieldset($fieldsetOrType, $sContainerName, $oDocument = null) {
// we want to create:
//
@@ -82,32 +82,32 @@ class KTFieldsetRegistry {
// - widgets
//
// use $oDocument as a stub *if* its set.
-
+
}
function widgetsForFieldset($fieldsetOrType, $sContainerName, $oDocument = null) {
// this is likely to be called repeatedly.
if (is_null($this->oWF)) {
- $this->oWF =& KTWidgetFactory::getSingleton();
- }
-
+ $this->oWF =& KTWidgetFactory::getSingleton();
+ }
+
// we're going to create one of two things, here:
// - conditional fieldset widget
// - a "Fieldset" widget
-
+
// FIXME delegate.
$oFieldset =& $fieldsetOrType;
if ($oFieldset->getIsConditional()) {
- return PEAR::raiseError(_kt("Conditional Fieldsets are not yet implemented"));
+ return PEAR::raiseError(_kt("Conditional Fieldsets are not yet implemented"));
} else {
$widgets = array();
$fields = $oFieldset->getFields();
-
+
foreach ($fields as $oField) {
- $fname = 'metadata_' . $oField->getId();
+ $fname = 'metadata_' . $oField->getId();
$value = null;
-
+
// check if we had an old value
if (!is_null($oDocument)) {
$oFL = DocumentFieldLink::getByDocumentAndField($oDocument, $oField);
@@ -115,7 +115,7 @@ class KTFieldsetRegistry {
$value = $oFL->getValue();
}
}
-
+
// we have to hack in support for the hardcoded types of fields
// handled by the "generic" widget.
//
@@ -150,7 +150,7 @@ class KTFieldsetRegistry {
'id_method' => 'getName',
'label_method' => 'getName',
'unselected_label' => _kt("No selection."),
- 'simple_select' => false,
+ 'simple_select' => false,
));
} else if ($type == 'ktcore.fields.tree') {
$widgets[] = $this->oWF->get('ktcore.widgets.treemetadata', array(
@@ -164,7 +164,7 @@ class KTFieldsetRegistry {
));
}
}
-
+
return array($this->oWF->get('ktcore.widgets.fieldset',array(
'label' => $oFieldset->getName(),
'description' => $oFieldset->getDescription(),
@@ -173,33 +173,36 @@ class KTFieldsetRegistry {
)));
}
}
-
+
function validatorsForFieldset($fieldsetOrType, $sContainerName, $oDocument = null, $bIncludeAuto = false) {
// this is likely to be called repeatedly.
if (is_null($this->oVF)) {
- $this->oVF =& KTValidatorFactory::getSingleton();
- }
-
+ $this->oVF =& KTValidatorFactory::getSingleton();
+ }
+
// FIXME delegate.
$oFieldset =& $fieldsetOrType;
if ($oFieldset->getIsConditional()) {
- return PEAR::raiseError(_kt("Conditional Fieldsets are not yet implemented"));
+ return PEAR::raiseError(_kt("Conditional Fieldsets are not yet implemented"));
} else {
$validators = array();
$fields = $oFieldset->getFields();
-
+
if ($bIncludeAuto) {
// we need to do *all* validation
// since we may be used outside a form.
//
// to prevent code duplication, we cheat and get the autovalidators
// this makes add/edit forms marginally less efficient, but we'll deal.
-
+
$widgets = $this->widgetsForFieldset($oFieldset, $sContainerName, $sDocument);
$validators = kt_array_merge($validators, $widgets[0]->getValidators());
}
-
+
+ $config = KTConfig::getSingleton();
+ $maxLength = $config->get('KnowledgeTree/maxMetadataLength',10240);
+
foreach ($fields as $oField) {
$type = '';
@@ -212,11 +215,12 @@ class KTFieldsetRegistry {
} else {
$type = 'ktcore.fields.string';
}
-
+
$fname = 'metadata_' . $oField->getId();
if ($type == 'ktcore.fields.string') {
$validators[] = $this->oVF->get('ktcore.validators.string',array(
'test' => $fname,
+ 'max_length'=>$maxLength,
'output' => $fname,
));
} else if ($type == 'ktcore.fields.lookup') {
@@ -238,14 +242,14 @@ class KTFieldsetRegistry {
$validators[] = PEAR::raiseError(sprintf(_kt("Unable to deal with field: id %d"), $oField->getId()));
}
}
-
+
return array($this->oVF->get('ktcore.validators.fieldset',array(
'test' => $sContainerName,
'output' => $sContainerName,
'validators' => $validators,
)));
}
- }
+ }
}
?>
diff --git a/lib/permissions/permissionutil.inc.php b/lib/permissions/permissionutil.inc.php
index 2ffb6e4..40aa491 100644
--- a/lib/permissions/permissionutil.inc.php
+++ b/lib/permissions/permissionutil.inc.php
@@ -196,15 +196,41 @@ class KTPermissionUtil {
$sWhere = 'permission_object_id = ?';
$aParams = array($oPO->getID());
$aFolders =& Folder::getList(array($sWhere, $aParams));
+
+ // init once time those var for speeding up updates
+ $oChannel =& KTPermissionChannel::getSingleton();
+ $aPermAssigns = KTPermissionAssignment::getByObjectMulti($oPO);
+ $aMapPermAllowed = array();
+ foreach ($aPermAssigns as $oPermAssign) {
+ $oPermDescriptor = KTPermissionDescriptor::get($oPermAssign->getPermissionDescriptorID());
+ $aGroupIDs = $oPermDescriptor->getGroups();
+ $aUserIDs = array();
+ $aRoleIDs = $oPermDescriptor->getRoles();
+ $aAllowed = array(
+ 'group' => $aGroupIDs,
+ 'user' => $aUserIDs,
+ 'role' => $aRoleIDs,
+ );
+ $aMapPermAllowed[$oPermAssign->getPermissionID()] = $aAllowed;
+ }
+ $aMapPermDesc = array();
+ foreach ($aMapPermAllowed as $iPermissionId => $aAllowed) {
+ $oLookupPD = KTPermissionUtil::getOrCreateDescriptor($aAllowed);
+ $aMapPermDesc[$iPermissionId] = $oLookupPD->getID();
+ }
+
+ $oPermLookup = KTPermissionLookupAssignment::findOrCreateLookupByPermissionDescriptorMap($aMapPermDesc);
+ $aOptions = array('channel' => $oChannel, 'map_allowed' => $aMapPermAllowed, 'perm_lookup' => $oPermLookup);
+
if (!PEAR::isError($aFolders)) {
foreach ($aFolders as $oFolder) {
- KTPermissionUtil::updatePermissionLookup($oFolder);
+ KTPermissionUtil::updatePermissionLookup($oFolder, $aOptions);
}
}
$aDocuments =& Document::getList(array($sWhere, $aParams));
if (!PEAR::isError($aDocuments)) {
foreach ($aDocuments as $oDocument) {
- KTPermissionUtil::updatePermissionLookup($oDocument);
+ KTPermissionUtil::updatePermissionLookup($oDocument, $aOptions);
}
}
}
@@ -248,18 +274,29 @@ class KTPermissionUtil {
* Update's the permission lookup on one folder or document,
* non-recursively.
*/
- function updatePermissionLookup(&$oFolderOrDocument) {
- if (!is_a($oFolderOrDocument, 'Folder')) {
- if (!is_a($oFolderOrDocument, 'Document')) {
- if (!is_a($oFolderOrDocument, 'KTDocumentCore')) {
- return ; // we occasionally get handed a PEAR::raiseError. Just ignore it.
- }
- }
- }
-
- $oChannel =& KTPermissionChannel::getSingleton();
- if (is_a($oFolderOrDocument, 'Folder')) {
- $msg = sprintf("Updating folder %s", join("/", $oFolderOrDocument->getPathArray()));
+ function updatePermissionLookup(&$oFolderOrDocument, $aOptions = null) {
+ $is_a_folder = is_a($oFolderOrDocument, 'Folder');
+ $is_a_document = is_a($oFolderOrDocument, 'Document') || is_a($oFolderOrDocument, 'KTDocumentCore');
+
+ $oChannel = null;
+ $aMapPermAllowed = null;
+ $oPermLookup = null;
+ if (!is_null($aOptions)) {
+ $oChannel = $aOptions['channel'];
+ $aMapPermAllowed = $aOptions['map_allowed'];
+ $oPermLookup = $aOptions['perm_lookup'];
+ }
+
+ if (!$is_a_folder && !$is_a_document) {
+ return ; // we occasionally get handed a PEAR::raiseError. Just ignore it.
+ }
+
+
+ if (is_null($oChannel)) {
+ $oChannel =& KTPermissionChannel::getSingleton();
+ }
+ if ($is_a_folder) {
+ $msg = sprintf("Updating folder %s", join('/', $oFolderOrDocument->getPathArray()));
} else {
if (is_a($oFolderOrDocument, 'Document')) {
$msg = sprintf("Updating document %s", $oFolderOrDocument->getName());
@@ -273,23 +310,26 @@ class KTPermissionUtil {
if (empty($iPermissionObjectId)) {
return;
}
- $oPO = KTPermissionObject::get($iPermissionObjectId);
- $aPAs = KTPermissionAssignment::getByObjectMulti($oPO);
- $aMapPermAllowed = array();
- foreach ($aPAs as $oPA) {
- $oPD = KTPermissionDescriptor::get($oPA->getPermissionDescriptorID());
- $aGroupIDs = $oPD->getGroups();
- $aUserIDs = array();
- $aRoleIDs = $oPD->getRoles();
- $aAllowed = array(
- "group" => $aGroupIDs,
- "user" => $aUserIDs,
- "role" => $aRoleIDs,
- );
- $aMapPermAllowed[$oPA->getPermissionID()] = $aAllowed;
- }
-
- if (!is_a($oFolderOrDocument, 'Folder')) {
+
+ if (is_null($aMapPermAllowed)) {
+ $oPO = KTPermissionObject::get($iPermissionObjectId);
+ $aPAs = KTPermissionAssignment::getByObjectMulti($oPO);
+ $aMapPermAllowed = array();
+ foreach ($aPAs as $oPA) {
+ $oPD = KTPermissionDescriptor::get($oPA->getPermissionDescriptorID());
+ $aGroupIDs = $oPD->getGroups();
+ $aUserIDs = array();
+ $aRoleIDs = $oPD->getRoles();
+ $aAllowed = array(
+ 'group' => $aGroupIDs,
+ 'user' => $aUserIDs,
+ 'role' => $aRoleIDs,
+ );
+ $aMapPermAllowed[$oPA->getPermissionID()] = $aAllowed;
+ }
+ }
+
+ if (!$is_a_folder) {
$aDynamicConditions = KTPermissionDynamicCondition::getByPermissionObject($oPO);
if (!PEAR::isError($aDynamicConditions)) {
foreach ($aDynamicConditions as $oDynamicCondition) {
@@ -299,7 +339,7 @@ class KTPermissionUtil {
$aPermissionIds = $oDynamicCondition->getAssignment();
foreach ($aPermissionIds as $iPermissionId) {
$aCurrentAllowed = KTUtil::arrayGet($aMapPermAllowed, $iPermissionId, array());
- $aCurrentAllowed["group"][] = $iGroupId;
+ $aCurrentAllowed['group'][] = $iGroupId;
$aMapPermAllowed[$iPermissionId] = $aCurrentAllowed;
}
}
@@ -307,7 +347,7 @@ class KTPermissionUtil {
}
}
- if (!is_a($oFolderOrDocument, 'Folder')) {
+ if (!$is_a_folder) {
$oState = KTWorkflowUtil::getWorkflowStateForDocument($oFolderOrDocument);
if (!(PEAR::isError($oState) || is_null($oState) || ($oState == false))) {
$aWorkflowStatePermissionAssignments = KTWorkflowStatePermissionAssignment::getByState($oState);
@@ -320,9 +360,9 @@ class KTPermissionUtil {
$aUserIDs = array();
$aRoleIDs = $oPD->getRoles();
$aAllowed = array(
- "group" => $aGroupIDs,
- "user" => $aUserIDs,
- "role" => $aRoleIDs,
+ 'group' => $aGroupIDs,
+ 'user' => $aUserIDs,
+ 'role' => $aRoleIDs,
);
$aMapPermAllowed[$iPermissionId] = $aAllowed;
}
@@ -331,8 +371,11 @@ class KTPermissionUtil {
// if we have roles: nearest folder.
$iRoleSourceFolder = null;
- if (is_a($oFolderOrDocument, 'KTDocumentCore') || is_a($oFolderOrDocument, 'Document')) { $iRoleSourceFolder = $oFolderOrDocument->getFolderID(); }
- else { $iRoleSourceFolder = $oFolderOrDocument->getId(); }
+ if ($is_a_document) {
+ $iRoleSourceFolder = $oFolderOrDocument->getFolderID();
+ }else {
+ $iRoleSourceFolder = $oFolderOrDocument->getId();
+ }
// very minor perf win: map role_id (in context) to PD.
$_roleCache = array();
@@ -350,7 +393,7 @@ class KTPermissionUtil {
}
if (!array_key_exists($iRoleId, $_roleCache)) {
$oRoleAllocation = null;
- if (is_a($oFolderOrDocument, 'KTDocumentCore') || is_a($oFolderOrDocument, 'Document')) {
+ if ($is_a_document) {
$oRoleAllocation =& DocumentRoleAllocation::getAllocationsForDocumentAndRole($oFolderOrDocument->getId(), $iRoleId);
if (PEAR::isError($oRoleAllocation)) { $oRoleAllocation = null; }
}
@@ -387,14 +430,17 @@ class KTPermissionUtil {
*/
- $aMapPermDesc = array();
- foreach ($aMapPermAllowed as $iPermissionId => $aAllowed) {
- $oLookupPD = KTPermissionUtil::getOrCreateDescriptor($aAllowed);
- $aMapPermDesc[$iPermissionId] = $oLookupPD->getID();
+ if (is_null($oPermLookup)) {
+ $aMapPermDesc = array();
+ foreach ($aMapPermAllowed as $iPermissionId => $aAllowed) {
+ $oLookupPD = KTPermissionUtil::getOrCreateDescriptor($aAllowed);
+ $aMapPermDesc[$iPermissionId] = $oLookupPD->getID();
+ }
+
+ $oPermLookup = KTPermissionLookupAssignment::findOrCreateLookupByPermissionDescriptorMap($aMapPermDesc);
}
- $oPL = KTPermissionLookupAssignment::findOrCreateLookupByPermissionDescriptorMap($aMapPermDesc);
- $oFolderOrDocument->setPermissionLookupID($oPL->getID());
+ $oFolderOrDocument->setPermissionLookupID($oPermLookup->getID());
$oFolderOrDocument->update();
}
// }}}
diff --git a/lib/plugins/plugin.inc.php b/lib/plugins/plugin.inc.php
index f33e1cc..55f4517 100644
--- a/lib/plugins/plugin.inc.php
+++ b/lib/plugins/plugin.inc.php
@@ -395,6 +395,9 @@ class KTPlugin {
$query = "SELECT * FROM plugin_helper h WHERE plugin = '{$this->sNamespace}'";
$aPluginHelpers = DBUtil::getResultArray($query);
+ // Include any required resources, javascript files, etc
+ $this->run_setup();
+
if(!empty($aPluginHelpers)){
foreach ($aPluginHelpers as $plugin) {
$sName = $plugin['namespace'];
@@ -632,6 +635,10 @@ class KTPlugin {
return;
}
+ function run_setup() {
+ return;
+ }
+
function stripKtDir($sFilename) {
if (strpos($sFilename, KT_DIR) === 0 ||strpos($sFilename, realpath(KT_DIR)) === 0) {
return substr($sFilename, strlen(KT_DIR) + 1);
diff --git a/lib/storage/ondiskhashedstoragemanager.inc.php b/lib/storage/ondiskhashedstoragemanager.inc.php
index 7402f28..1e68b2c 100644
--- a/lib/storage/ondiskhashedstoragemanager.inc.php
+++ b/lib/storage/ondiskhashedstoragemanager.inc.php
@@ -44,7 +44,14 @@ require_once(KT_LIB_DIR . '/documentmanagement/documentcontentversion.inc.php');
require_once(KT_LIB_DIR . '/filelike/fsfilelike.inc.php');
class KTOnDiskHashedStorageManager extends KTStorageManager {
- function upload(&$oDocument, $sTmpFilePath) {
+ function upload(&$oDocument, $sTmpFilePath, $aOptions = null) {
+
+ if (!file_exists($sTmpFilePath)) {
+
+ return new PEAR_Error("$sTmpFilePath does not exist so we can't copy it into the repository! Options: " . print_r($aOptions,true) );
+ }
+
+
$oConfig =& KTConfig::getSingleton();
$sStoragePath = $this->generateStoragePath($oDocument);
if (PEAR::isError($sStoragePath)) {
@@ -60,7 +67,7 @@ class KTOnDiskHashedStorageManager extends KTStorageManager {
if (OS_WINDOWS) {
$sDocumentFileSystemPath = str_replace('\\','/',$sDocumentFileSystemPath);
}
- if ($this->writeToFile($sTmpFilePath, $sDocumentFileSystemPath)) {
+ if ($this->writeToFile($sTmpFilePath, $sDocumentFileSystemPath, $aOptions)) {
$end_time = KTUtil::getBenchmarkTime();
global $default;
$default->log->info(sprintf("Uploaded %d byte file in %.3f seconds", $file_size, $end_time - $start_time));
@@ -70,10 +77,10 @@ class KTOnDiskHashedStorageManager extends KTStorageManager {
if (file_exists($sDocumentFileSystemPath)) {
return true;
} else {
- return false;
+ return new PEAR_Error("$sDocumentFileSystemPath does not exist after write to storage path. Options: " . print_r($aOptions,true));
}
} else {
- return false;
+ return new PEAR_Error("Could not write $sTmpFilePath to $sDocumentFileSystemPath with options: " . print_r($aOptions,true));
}
}
@@ -100,8 +107,11 @@ class KTOnDiskHashedStorageManager extends KTStorageManager {
return false;
}
- function writeToFile($sTmpFilePath, $sDocumentFileSystemPath) {
+ function writeToFile($sTmpFilePath, $sDocumentFileSystemPath, $aOptions = null) {
// Make it easy to write compressed/encrypted storage
+ if(isset($aOptions['copy_upload']) && ($aOptions['copy_upload'] == 'true')) {
+ return copy($sTmpFilePath, $sDocumentFileSystemPath);
+ }
if (is_uploaded_file($sTmpFilePath))
return move_uploaded_file($sTmpFilePath, $sDocumentFileSystemPath);
diff --git a/lib/templating/kt3template.inc.php b/lib/templating/kt3template.inc.php
index 447395d..b675088 100644
--- a/lib/templating/kt3template.inc.php
+++ b/lib/templating/kt3template.inc.php
@@ -130,7 +130,7 @@ class KTPage {
$aJS[] = 'thirdpartyjs/MochiKit/MochiKitPacked.js';
$aJS[] = 'resources/js/kt-utility.js';
$aJS[] = 'presentation/i18nJavascript.php';
- $aJS[] = 'thirdpartyjs/curvycorners/rounded_corners_lite.inc.js';
+ $aJS[] = 'thirdpartyjs/curvycorners/rounded_corners.inc.js';
$aJS[] = 'resources/js/loader.js';
$aJS[] = 'thirdpartyjs/yui/tools/tools.js';
$aJS[] = 'thirdpartyjs/yui/connection/connection.js';
diff --git a/lib/triggers/triggerregistry.inc.php b/lib/triggers/triggerregistry.inc.php
index 6ec6877..32a1844 100644
--- a/lib/triggers/triggerregistry.inc.php
+++ b/lib/triggers/triggerregistry.inc.php
@@ -5,32 +5,32 @@
* KnowledgeTree Open Source Edition
* Document Management Made Simple
* Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited
- *
+ *
* 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 The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
* Blake Street, Observatory, 7925 South Africa. 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
- * copyright notice.
+ * must display the words "Powered by KnowledgeTree" and retain the original
+ * copyright notice.
* Contributor( s): ______________________________________
*
*/
@@ -78,7 +78,7 @@ class KTTriggerRegistry {
if (!class_exists($trigger[0]))
{
global $default;
- $defailt->log->error(sprintf(_kt('Cannot locate trigger class \'%s\' for action \'%s\' slot \'%s\'.'), $trigger[0], $action, $slot));
+ $default->log->error(sprintf(_kt('Cannot locate trigger class \'%s\' for action \'%s\' slot \'%s\'.'), $trigger[0], $action, $slot));
}
}
}
diff --git a/lib/upgrades/UpgradeFunctions.inc.php b/lib/upgrades/UpgradeFunctions.inc.php
index 1876a02..3b64b7b 100644
--- a/lib/upgrades/UpgradeFunctions.inc.php
+++ b/lib/upgrades/UpgradeFunctions.inc.php
@@ -1011,6 +1011,7 @@ class UpgradeFunctions {
$ini->addItem('clientToolPolicies', 'captureReasonsCancelCheckout', 'true');
$ini->addItem('clientToolPolicies', 'captureReasonsCopyInKT', 'true');
$ini->addItem('clientToolPolicies', 'captureReasonsMoveInKT', 'true');
+ $ini->addItem('clientToolPolicies', 'allowRememberPassword', 'true');
// DiskUsage Section
$ini->addItem('DiskUsage', 'warningThreshold', '10', "When free space in a mount point is less than this percentage,\r\n; the disk usage dashlet will highlight the mount in ORANGE", "settings for the Disk Usage dashlet");
diff --git a/lib/users/User.inc b/lib/users/User.inc
index 192a017..4d54a9f 100644
--- a/lib/users/User.inc
+++ b/lib/users/User.inc
@@ -7,32 +7,32 @@
* KnowledgeTree Open Source Edition
* Document Management Made Simple
* Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited
- *
+ *
* 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 The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
* Blake Street, Observatory, 7925 South Africa. 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
- * copyright notice.
+ * must display the words "Powered by KnowledgeTree" and retain the original
+ * copyright notice.
* Contributor( s): ______________________________________
*/
@@ -455,4 +455,26 @@ class User extends KTEntity {
return;
}
+
+ function hasPermission(&$oPermissionDescriptor) {
+ $pdgTable = KTUtil::getTableName('permission_descriptor_groups');
+ global $default;
+ $uglTable = $default->users_groups_table;
+
+ $sQuery = "SELECT COUNT(*) AS num FROM $pdgTable INNER JOIN " .
+ "$uglTable ON $uglTable.group_id=$pdgTable.group_id" .
+ "WHERE $pdgTable.descriptor_id = ? AND " .
+ "$uglTable.user_id=?";
+ $aParams = array($oPermissionDescriptor->getID());
+ $aParams[] = $this->$iId;
+ $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'num');
+ if (PEAR::isError($res)) {
+ return $res;
+ }
+ if ((int)$res === 0) {
+ return false;
+ }
+ return true;
+ }
}
+?>
\ No newline at end of file
diff --git a/lib/util/ktutil.inc b/lib/util/ktutil.inc
index ddf6227..a2dfecd 100644
--- a/lib/util/ktutil.inc
+++ b/lib/util/ktutil.inc
@@ -44,8 +44,10 @@ class KTUtil {
const HOUR_IN_SECS = 3600;
const DAY_IN_SECS = 86400;
const KB = 1024;
- const MB = 1048576;
- const GB = 1073741824;
+ const MB = 1048576;
+ const GB = 1073741824;
+ const TB = 1099511627776;
+ const PB = 1125899906842624;
static function computePeriod($diff, $suffix = null, $returnArray=false)
{
@@ -89,21 +91,29 @@ class KTUtil {
{
$filesize = (int) $filesize;
- if ($filesize >= KTutil::GB)
+ if ($filesize >= KTUtil::PB)
{
- return number_format($filesize / KTutil::GB, 2, '.',',') . _kt('GB');
+ return number_format($filesize / KTUtil::PB, 2, '.',',') . _kt('PB');
}
- elseif ($filesize >= KTutil::MB)
+ elseif ($filesize >= KTUtil::TB)
{
- return number_format($filesize / KTutil::MB, 2, '.',',') . _kt('MB');
+ return number_format($filesize / KTUtil::TB, 2, '.',',') . _kt('TB');
}
- elseif ($filesize >= KTutil::KB)
+ elseif ($filesize >= KTUtil::GB)
{
- return number_format($filesize / KTutil::KB, 2, '.',',') . _kt('KB');
+ return number_format($filesize / KTUtil::GB, 2, '.',',') . _kt('GB');
+ }
+ elseif ($filesize >= KTUtil::MB)
+ {
+ return number_format($filesize / KTUtil::MB, 2, '.',',') . _kt('MB');
+ }
+ elseif ($filesize >= KTUtil::KB)
+ {
+ return number_format($filesize / KTUtil::KB, 2, '.',',') . _kt('KB');
}
else
{
- return $filesize . _kt('b');
+ return $filesize . _kt('B');
}
}
diff --git a/lib/util/sanitize.inc b/lib/util/sanitize.inc
index c331a70..b52bfd3 100644
--- a/lib/util/sanitize.inc
+++ b/lib/util/sanitize.inc
@@ -7,32 +7,32 @@
* KnowledgeTree Open Source Edition
* Document Management Made Simple
* Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited
- *
+ *
* 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 The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
* Blake Street, Observatory, 7925 South Africa. 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
- * copyright notice.
+ * must display the words "Powered by KnowledgeTree" and retain the original
+ * copyright notice.
* Contributor( s): ______________________________________
*/
@@ -57,13 +57,13 @@ function sanitize($string) {
}
function sanitizeForSQL($string, $min='', $max='') {
-
+
$string = trim($string);
if(get_magic_quotes_gpc()) $string = stripslashes($string);
-
+
$len = strlen($string);
if((($min != '') && ($len < $min)) || (($max != '') && ($len > $max))) return false;
-
+
if(function_exists("mysql_real_escape_string")) {
return mysql_real_escape_string($string);
} else {
@@ -71,12 +71,10 @@ function sanitizeForSQL($string, $min='', $max='') {
}
}
-function sanitizeForSQLtoHTML($string, $min='', $max='') {
-
- $string = str_ireplace("\r", '', $string);
- $string = str_ireplace("\n", '', $string);
- return stripslashes(trim($string));
-
+function sanitizeForSQLtoHTML($string, $min='', $max='')
+{
+ $string = str_replace(array("\r","\n"), array('',''), $string);
+ return $string;
}
function sanitizeForHTML($string, $min='', $max='')
@@ -86,7 +84,7 @@ function sanitizeForHTML($string, $min='', $max='')
$len = strlen($string);
if((($min != '') && ($len < $min)) || (($max != '') && ($len > $max))) return false;
-
+
if(function_exists("htmlspecialchars")) {
return htmlspecialchars($string);
} else {
@@ -123,8 +121,8 @@ function sanitizeForSYSTEM($string, $min='', $max='')
$len = strlen($string);
if((($min != '') && ($len < $min)) || (($max != '') && ($len > $max))) return false;
-
- $pattern = '/( ;|\||`|>|<|&|^|"|'."\n|\r|'".'|{|}|[|]|\)|\( )/i';
+
+ $pattern = '/( ;|\||`|>|<|&|^|"|'."\n|\r|'".'|{|}|[|]|\)|\( )/i';
$string = preg_replace( $pattern, '', $string);
return '"'.preg_replace( '/\$/', '\\\$', $string).'"';
}
diff --git a/lib/validation/customerrorhandler.php b/lib/validation/customerrorhandler.php
new file mode 100644
index 0000000..aaa5cbf
--- /dev/null
+++ b/lib/validation/customerrorhandler.php
@@ -0,0 +1,63 @@
+toString(),1,2) == 'db')
+ {
+ $sErrorType = 'database_error';
+ }
+ else
+ {
+ $sErrorType = 'unknown_error';
+ }
+
+
+ $default->log->error($oError->toString());
+
+ }
+ }
+ ?>
\ No newline at end of file
diff --git a/lib/validation/customerrorviewer.inc.php b/lib/validation/customerrorviewer.inc.php
new file mode 100644
index 0000000..1cb6478
--- /dev/null
+++ b/lib/validation/customerrorviewer.inc.php
@@ -0,0 +1,129 @@
+get('CustomErrorMessages/customerrormessages');
+ return $sCustomErrorCheck;
+ }
+ //}}}
+
+ //{{{ getCustomErrorHandlerSetting()
+ function getCustomErrorHandlerSetting()
+ {
+ $oKTConfig =& KTConfig::getSingleton();
+ $sCustomErrorCheck = $oKTConfig->get('CustomErrorMessages/customerrorhandler');
+ return $sCustomErrorCheck;
+ }
+ //}}}
+
+ // {{{ getCustomErrorRedirectPage()
+ function getCustomErrorRedirectPage ()
+ {
+ $oKTErrorConfig =& KTConfig::getSingleton();
+ $sCustomErrorPage = $oKTErrorConfig->get('CustomErrorMessages/customerrorpagepath');
+
+ //if a filname is specified in the config.ini file make it into a url
+ if (substr($sCustomErrorPage, 0, 4) != 'http')
+ {
+
+ $sCustomErrorPage = 'http://'.$_SERVER['HTTP_HOST'].'/'.$sCustomErrorPage;
+
+ }
+
+ //checking if file exists
+ //curl options will return the page header, we can then check for an http error
+ $CurlSession = curl_init();
+ curl_setopt($CurlSession, CURLOPT_URL, $sCustomErrorPage);
+ curl_setopt($CurlSession, CURLOPT_HEADER, true);
+ curl_setopt($CurlSession, CURLOPT_NOBODY, true);
+ curl_setopt($CurlSession, CURLOPT_RETURNTRANSFER, true);
+ $data = curl_exec($CurlSession);
+ curl_close($CurlSession);
+ preg_match("/HTTP\/1\.[1|0]\s(\d{3})/",$data,$matches);
+
+ //checking for http error - if the retunr code isn't 200 then we have an error
+ //on an error we return 0
+ if ($matches[1] != '200')
+ {
+ //if file does not exist return error code of 0
+ return '0';
+ }
+ else
+ {
+ //if file exists return error page address
+ return $sCustomErrorPage;
+
+ }
+ }
+ // }}}
+
+ // {{{ customErrorPageRedirect()
+ function doCustomErrorPageRedirect($CustomErrorPage, $oError = null)
+ {
+ $sErrorMessage = '';
+ if($oError != null)
+ {
+ //call error handler
+
+ $aErrorMessage = array ();
+ $aErrorMessage['Error_MessageOne'] = $oError->getMessage();
+ $aErrorMessage['Error_MessageTwo'] = $oError->getUserInfo();
+ //echo '
';
+ //print_r($aErrorMessage);
+ //echo '
';
+ //exit;
+ $customErrorHandler = KTCustomErrorHandler::initCustomErrorHandler();
+ $customErrorHandler->logError($oError);
+ }
+
+ $ErrorPageCurlSession = curl_init($CustomErrorPage);
+ //curl_setopt($ErrorPageCurlSession, CURLOPT_SSL_VERIFYPEER, false);
+ curl_setopt($ErrorPageCurlSession, CURLOPT_POST, true);
+ curl_setopt($ErrorPageCurlSession, CURLOPT_POSTFIELDS, $aErrorMessage);
+ $ErrorPageSent = curl_exec($ErrorPageCurlSession);
+ curl_close($ErrorPageCurlSession);
+
+ }
+ // }}}
+ }
+ ?>
diff --git a/lib/widgets/fieldsetDisplay.inc.php b/lib/widgets/fieldsetDisplay.inc.php
index c5ea77a..03bb154 100644
--- a/lib/widgets/fieldsetDisplay.inc.php
+++ b/lib/widgets/fieldsetDisplay.inc.php
@@ -5,32 +5,32 @@
* KnowledgeTree Open Source Edition
* Document Management Made Simple
* Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited
- *
+ *
* 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 The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
* Blake Street, Observatory, 7925 South Africa. 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
- * copyright notice.
+ * must display the words "Powered by KnowledgeTree" and retain the original
+ * copyright notice.
* Contributor( s): ______________________________________
*
*/
@@ -45,20 +45,20 @@
* "document_id" => $iDocumentId
*
*/
-
+
// boilerplate
-require_once(KT_LIB_DIR . "/templating/templating.inc.php");
-require_once(KT_LIB_DIR . "/database/dbutil.inc");
+require_once(KT_LIB_DIR . '/templating/templating.inc.php');
+require_once(KT_LIB_DIR . '/database/dbutil.inc');
-require_once(KT_LIB_DIR . "/documentmanagement/MDTree.inc"); // :(
+require_once(KT_LIB_DIR . '/documentmanagement/MDTree.inc'); // :(
// data acquisition
-require_once(KT_LIB_DIR . "/users/User.inc");
+require_once(KT_LIB_DIR . '/users/User.inc');
require_once(KT_LIB_DIR . '/documentmanagement/MetaData.inc');
-require_once(KT_LIB_DIR . "/widgets/FieldsetDisplayRegistry.inc.php");
-require_once(KT_LIB_DIR . "/widgets/fieldWidgets.php");
+require_once(KT_LIB_DIR . '/widgets/FieldsetDisplayRegistry.inc.php');
+require_once(KT_LIB_DIR . '/widgets/fieldWidgets.php');
/* it may be useful to move this to a factory, eventually? */
@@ -77,9 +77,9 @@ function getWidgetForMetadataField($field, $current_value, $page, $errors = null
if ($errors === null) {
$fieldErrors = array();
} else {
- $fieldErrors = $errors;
+ $fieldErrors = $errors;
}
-
+
// now we need to break, based on a few aspects of the oField (DocumentField)
if ($field->getHasLookup()) {
@@ -90,34 +90,47 @@ function getWidgetForMetadataField($field, $current_value, $page, $errors = null
// extract the lookup.
if ($vocab === null) { // allow override
$lookups = MetaData::getEnabledByDocumentField($field);
- $fieldOptions["vocab"] = array(); // FIXME handle lookups
- $fieldOptions['vocab'][''] = _kt('Select a value');
+ $fieldOptions['vocab'] = array(); // FIXME handle lookups
+ $fieldOptions['vocab'][''] = _kt('Select a value');
foreach ($lookups as $md) {
- $fieldOptions["vocab"][$md->getName()] = $md->getName();
+ $fieldOptions['vocab'][$md->getName()] = $md->getName();
}
} else {
- $fieldOptions["vocab"] = $vocab;
+ $fieldOptions['vocab'] = $vocab;
}
-
- $oField = new KTLookupWidget($fieldLabel, $fieldDescription, $fieldName, $fieldValue, $page, $fieldRequired, null, $fieldErrors, $fieldOptions);
+
+ $oField = new KTLookupWidget($fieldLabel, $fieldDescription, $fieldName, $fieldValue, $page, $fieldRequired, null, $fieldErrors, $fieldOptions);
} else {
// FIXME vocab's are _not_ supported for tree-inputs. this means conditional-tree-widgets are not unsupported.
-
+
// for trees, we are currently brutal.
$fieldTree = new MDTree();
$fieldTree->buildForField($field->getId());
$fieldTree->setActiveItem($current_value);
$fieldOptions['tree'] = $fieldTree->_evilTreeRenderer($fieldTree, $fieldName);
-
- $oField = new KTTreeWidget($fieldLabel, $fieldDescription, $fieldName, $fieldValue, $page, $fieldRequired, null, $fieldErrors, $fieldOptions);
+
+ $oField = new KTTreeWidget($fieldLabel, $fieldDescription, $fieldName, $fieldValue, $page, $fieldRequired, null, $fieldErrors, $fieldOptions);
}
} else {
- $oField = new KTBaseWidget($fieldLabel, $fieldDescription, $fieldName, $fieldValue, $page, $fieldRequired, null, $fieldErrors, $fieldOptions);
+ $oField = new KTBaseWidget($fieldLabel, $fieldDescription, $fieldName, $fieldValue, $page, $fieldRequired, null, $fieldErrors, $fieldOptions);
}
return $oField;
}
+/**
+ * Compare the fields within a fieldset for alphabetising.
+ *
+ * @param object $a
+ * @param object $b
+ * @return integer
+ */
+function compareFieldSetField($a, $b)
+{
+ if ($a['field']->getName() == $b['field']->getName()) return 0;
+ if ($a['field']->getName() < $b['field']->getName()) return -1;
+ return 1;
+}
// FIXME need to establish some kind of api to pass in i18n information.
class KTFieldsetDisplay {
@@ -126,33 +139,33 @@ class KTFieldsetDisplay {
function KTFieldsetDisplay($oFieldset) {
$this->fieldset = $oFieldset;
}
-
+
function _dateHelper($dDate) {
$dColumnDate = strtotime($dDate);
- return date("Y-m-d H:i", $dColumnDate);
+ return date('Y-m-d H:i', $dColumnDate);
}
-
-
+
+
function _sizeHelper($size) {
$finalSize = $size;
$label = 'b';
-
+
if ($finalSize > 1000) { $label='Kb'; $finalSize = floor($finalSize/1000); }
if ($finalSize > 1000) { $label='Mb'; $finalSize = floor($finalSize/1000); }
return $finalSize . $label;
}
-
+
function _mimeHelper($iMimeTypeId) {
// FIXME lazy cache this.
// FIXME extend mime_types to have something useful to say.
$sQuery = 'SELECT * FROM mime_types WHERE id = ?';
$res = DBUtil::getOneResult(array($sQuery, array($iMimeTypeId)));
-
+
if (PEAR::isError($res)) {
return _kt('unknown type');
}
-
+
if (!empty($res['friendly_name'])) {
return _kt($res['friendly_name']);
} else {
@@ -160,19 +173,19 @@ class KTFieldsetDisplay {
}
}
-
-
+
+
// this should multiplex i18n_title
function getTitle() { return $this->sTitle; }
-
+
function render($aDocumentData) {
return '
Warning: Abstract Fieldset created.
';
}
-
+
function renderComparison($aDocumentData, $aComparisonData) {
return '
Not implemented: comparison rendering
';
}
-
+
// we need the $main to (potentially) add js, etc.
function renderEdit($document_data) {
return '
Not Implemented: fieldset editing.
';
@@ -188,29 +201,29 @@ class GenericFieldsetDisplay extends KTFieldsetDisplay {
// DON'T take anything.
function GenericFieldsetDisplay() {
-
+
}
-
+
function render($aDocumentData) {
// we do a fair bit of fetching, etc. in here.
- $document = $aDocumentData["document"];
+ $document = $aDocumentData['document'];
// creation
$creator =& User::get($document->getCreatorId());
if (PEAR::isError($creator)) {
- $creator_name = "" . _kt("Unable to find the document's creator") . "";
+ $creator_name = '' . _kt("Unable to find the document's creator") . '';
} else {
$creator_name = $creator->getName();
}
$owner =& User::get($document->getOwnerId());
if (PEAR::isError($owner)) {
- $owner_name = "" . _kt("Unable to find the document's owner") . "";
+ $owner_name = '' . _kt("Unable to find the document's owner") . '';
} else {
$owner_name = $owner->getName();
}
$modified_user =& User::get($document->getModifiedUserId());
if (PEAR::isError($modified_user)) {
- $modified_user_name = "" . _kt("Unable to find the document's modifier") . "";
+ $modified_user_name = '' . _kt("Unable to find the document's modifier") . '';
} else {
$modified_user_name = $modified_user->getName();
}
@@ -218,48 +231,48 @@ class GenericFieldsetDisplay extends KTFieldsetDisplay {
// last mod
$last_modified_date = $this->_dateHelper($document->getLastModifiedDate());
-
+
// document type // FIXME move this to view.php
- $document_type = $aDocumentData["document_type"]->getName();
+ $document_type = $aDocumentData['document_type']->getName();
$oWorkflow = KTWorkflowUtil::getWorkflowForDocument($document);
$oState = KTWorkflowUtil::getWorkflowStateForDocument($document);
-
-
- $oTemplating =& KTTemplating::getSingleton();
- $oTemplate = $oTemplating->loadTemplate("kt3/fieldsets/generic");
+
+
+ $oTemplating =& KTTemplating::getSingleton();
+ $oTemplate = $oTemplating->loadTemplate('kt3/fieldsets/generic');
$aTemplateData = array(
- "context" => $this,
- "document_data" => $aDocumentData,
- "document" => $aDocumentData["document"],
-
- "filename" => $document->getFileName(),
-
- "creator" => $creator_name,
- "owner" => $owner_name,
- "creation_date" => $creation_date,
-
- "last_modified_by" => $modified_user_name,
- "last_modified_date" => $last_modified_date,
-
- "document_type" => $document_type,
-
- "workflow_state" => $oState,
- "workflow" => $oWorkflow,
+ 'context' => $this,
+ 'document_data' => $aDocumentData,
+ 'document' => $aDocumentData['document'],
+
+ 'filename' => $document->getFileName(),
+
+ 'creator' => $creator_name,
+ 'owner' => $owner_name,
+ 'creation_date' => $creation_date,
+
+ 'last_modified_by' => $modified_user_name,
+ 'last_modified_date' => $last_modified_date,
+
+ 'document_type' => $document_type,
+
+ 'workflow_state' => $oState,
+ 'workflow' => $oWorkflow,
);
- return $oTemplate->render($aTemplateData);
+ return $oTemplate->render($aTemplateData);
}
-
+
function renderComparison($aDocumentData, $aComparisonData) {
// we do a fair bit of fetching, etc. in here.
- $document = $aDocumentData["document"];
- $comparison_document = $aComparisonData["document"];
+ $document = $aDocumentData['document'];
+ $comparison_document = $aComparisonData['document'];
// creation
$creator =& User::get($document->getCreatorId());
if (PEAR::isError($creator)) {
- $creator = "" . _kt("Unable to find the document's creator") . "";
+ $creator = '' . _kt("Unable to find the document's creator") . '';
} else {
$creator = $creator->getName();
}
@@ -268,30 +281,30 @@ class GenericFieldsetDisplay extends KTFieldsetDisplay {
// last mod
$last_modified_date = $this->_dateHelper($document->getVersionCreated());
$comparison_last_modified_date = $this->_dateHelper($comparison_document->getVersionCreated());
-
+
// document type // FIXME move this to view.php
- $document_type = $aDocumentData["document_type"]->getName();
- $comparison_document_type = $aComparisonData["document_type"]->getName();
-
+ $document_type = $aDocumentData['document_type']->getName();
+ $comparison_document_type = $aComparisonData['document_type']->getName();
+
$modified_user =& User::get($document->getVersionCreatorId());
if (PEAR::isError($modified_user)) {
- $modified_user = "" . _kt("Unable to find the document's modifier") . "";
+ $modified_user = "" . _kt("Unable to find the document's modifier") . '';
} else {
$modified_user = $modified_user->getName();
}
$owner_user =& User::get($document->getOwnerId());
if (PEAR::isError($owner_user)) {
- $owner_user = "" . _kt("Unable to find the document's owner") . "";
+ $owner_user = "" . _kt("Unable to find the document's owner") . '';
} else {
$owner_user = $owner_user->getName();
}
-
+
$comparison_modified_user =& User::get($comparison_document->getVersionCreatorId());
if (PEAR::isError($comparison_modified_user)) {
- $comparison_modified_user = "" . _kt("Unable to find the document's modifier") . "";
+ $comparison_modified_user = "" . _kt("Unable to find the document's modifier") . '';
} else {
$comparison_modified_user = $comparison_modified_user->getName();
}
@@ -300,59 +313,59 @@ class GenericFieldsetDisplay extends KTFieldsetDisplay {
$oState = KTWorkflowUtil::getWorkflowStateForDocument($document);
$oComparisonWorkflow = KTWorkflowUtil::getWorkflowForDocument($comparison_document);
$oComparisonState = KTWorkflowUtil::getWorkflowStateForDocument($comparison_document);
-
-
- $oTemplating =& KTTemplating::getSingleton();
- $oTemplate = $oTemplating->loadTemplate("kt3/fieldsets/generic_versioned");
+
+
+ $oTemplating =& KTTemplating::getSingleton();
+ $oTemplate = $oTemplating->loadTemplate('kt3/fieldsets/generic_versioned');
$aTemplateData = array(
- "context" => $this,
- "document_data" => $aDocumentData,
- "document" => $aDocumentData["document"],
-
- "title" => $document->getName(),
- "comparison_title" => $comparison_document->getName(),
-
- "filename" => $document->getFileName(),
- "comparison_filename" => $comparison_document->getFileName(),
-
- "creator" => $creator,
- "creation_date" => $creation_date,
- "owner" => $owner_user,
-
- "last_modified_by" => $modified_user,
- "last_modified_date" => $last_modified_date,
-
- "comparison_last_modified_by" => $comparison_modified_user,
- "comparison_last_modified_date" => $comparison_last_modified_date,
-
- "document_type" => $document_type,
- "comparison_document_type" => $comparison_document_type,
-
- "workflow_state" => $oState,
- "comparison_workflow_state" => $oComparisonState,
- "workflow" => $oWorkflow,
- "comparison_workflow" => $oComparisonWorkflow,
-
- "comparison_document" => $aComparisonData["document"],
+ 'context' => $this,
+ 'document_data' => $aDocumentData,
+ 'document' => $aDocumentData['document'],
+
+ 'title' => $document->getName(),
+ 'comparison_title' => $comparison_document->getName(),
+
+ 'filename' => $document->getFileName(),
+ 'comparison_filename' => $comparison_document->getFileName(),
+
+ 'creator' => $creator,
+ 'creation_date' => $creation_date,
+ 'owner' => $owner_user,
+
+ 'last_modified_by' => $modified_user,
+ 'last_modified_date' => $last_modified_date,
+
+ 'comparison_last_modified_by' => $comparison_modified_user,
+ 'comparison_last_modified_date' => $comparison_last_modified_date,
+
+ 'document_type' => $document_type,
+ 'comparison_document_type' => $comparison_document_type,
+
+ 'workflow_state' => $oState,
+ 'comparison_workflow_state' => $oComparisonState,
+ 'workflow' => $oWorkflow,
+ 'comparison_workflow' => $oComparisonWorkflow,
+
+ 'comparison_document' => $aComparisonData['document'],
);
-
- return $oTemplate->render($aTemplateData);
+
+ return $oTemplate->render($aTemplateData);
}
-
+
function renderEdit($document_data) {
global $main; // FIXME remove direct access to $main
- $oField = new KTBaseWidget(_kt("Document Title"),
+ $oField = new KTBaseWidget(_kt('Document Title'),
sprintf(_kt("The document title is used as the main name of a document throughout %s™."), APP_NAME),
- "generic_title", $document_data["document"]->getName(), $main, true, null, array());
+ 'generic_title', $document_data['document']->getName(), $main, true, null, array());
$aFields = array($oField); // its the only one editable from the basic set (currently).
-
- $oTemplating =& KTTemplating::getSingleton();
- $oTemplate = $oTemplating->loadTemplate("kt3/fieldsets/simple_editable");
+
+ $oTemplating =& KTTemplating::getSingleton();
+ $oTemplate = $oTemplating->loadTemplate('kt3/fieldsets/simple_editable');
$aTemplateData = array(
- "context" => $this,
- "fields" => $aFields,
- "title" => _kt("Generic Document Information"),
- "description" => sprintf(_kt("The information in this section is stored by %s™ for every document."), APP_NAME),
+ 'context' => $this,
+ 'fields' => $aFields,
+ 'title' => _kt('Generic Document Information'),
+ 'description' => sprintf(_kt("The information in this section is stored by %s™ for every document."), APP_NAME),
);
return $oTemplate->render($aTemplateData);
}
@@ -361,177 +374,184 @@ class GenericFieldsetDisplay extends KTFieldsetDisplay {
// The generic object
class SimpleFieldsetDisplay extends KTFieldsetDisplay {
-
+
function render($aDocumentData) {
// we do a fair bit of fetching, etc. in here.
- $document = $aDocumentData["document"];
-
+ $document = $aDocumentData['document'];
+
// we need to extract the fields.
$fields =& $this->fieldset->getFields();
-
-
+
+
// we now grab that subset of items which fit in here.
// FIXME link value -> lookup where appropriate.
// FIXME probably need to be more careful about the _type_ of field here.
$fieldset_values = array();
foreach ($fields as $oField) {
- $val = KTUtil::arrayGet($aDocumentData["field_values"], $oField->getId(), null);
- $fieldset_values[] = array("field" => $oField, "value" => $val, );
+ $val = KTUtil::arrayGet($aDocumentData['field_values'], $oField->getId(), null);
+ $fieldset_values[] = array('field' => $oField, 'value' => $val, );
+ }
+
+ // Alphabetise the metadata fields within a fieldset if set in config
+ $oKTConfig =& KTConfig::getSingleton();
+ $use_sort = $oKTConfig->get('ui/metadata_sort', false);
+
+ if($use_sort){
+ usort($fieldset_values, 'compareFieldSetField');
}
-
-
-
- $oTemplating =& KTTemplating::getSingleton();
- $oTemplate = $oTemplating->loadTemplate("kt3/fieldsets/simple");
+
+
+ $oTemplating =& KTTemplating::getSingleton();
+ $oTemplate = $oTemplating->loadTemplate('kt3/fieldsets/simple');
$aTemplateData = array(
- "context" => $this,
- "document_data" => $aDocumentData,
- "document" => $aDocumentData["document"],
- "fieldset" => $this->fieldset,
- "fieldset_values" => $fieldset_values,
- "description" => $this->fieldset->getDescription(),
+ 'context' => $this,
+ 'document_data' => $aDocumentData,
+ 'document' => $aDocumentData['document'],
+ 'fieldset' => $this->fieldset,
+ 'fieldset_values' => $fieldset_values,
+ 'description' => $this->fieldset->getDescription(),
);
- return $oTemplate->render($aTemplateData);
+ return $oTemplate->render($aTemplateData);
}
-
+
function renderComparison($aDocumentData, $aComparisonData) {
// we do a fair bit of fetching, etc. in here.
- $document = $aDocumentData["document"];
-
+ $document = $aDocumentData['document'];
+
// we need to extract the fields.
$fields =& $this->fieldset->getFields();
-
-
+
+
// we now grab that subset of items which fit in here.
// FIXME link value -> lookup where appropriate.
// FIXME probably need to be more careful about the _type_ of field here.
$fieldset_values = array();
foreach ($fields as $oField) {
- $curr_val = KTUtil::arrayGet($aDocumentData["field_values"], $oField->getId(), null);
- $old_val = KTUtil::arrayGet($aComparisonData["field_values"], $oField->getId(), null);
- $fieldset_values[] = array("field" => $oField, "current_value" => $curr_val, "previous_value" => $old_val);
+ $curr_val = KTUtil::arrayGet($aDocumentData['field_values'], $oField->getId(), null);
+ $old_val = KTUtil::arrayGet($aComparisonData['field_values'], $oField->getId(), null);
+ $fieldset_values[] = array('field' => $oField, 'current_value' => $curr_val, 'previous_value' => $old_val);
}
-
-
- $oTemplating =& KTTemplating::getSingleton();
- $oTemplate = $oTemplating->loadTemplate("kt3/fieldsets/simple_versioned");
+
+
+ $oTemplating =& KTTemplating::getSingleton();
+ $oTemplate = $oTemplating->loadTemplate('kt3/fieldsets/simple_versioned');
$aTemplateData = array(
- "context" => $this,
- "document_data" => $aDocumentData,
- "document" => $aDocumentData["document"],
- "fieldset" => $this->fieldset,
- "fieldset_values" => $fieldset_values,
+ 'context' => $this,
+ 'document_data' => $aDocumentData,
+ 'document' => $aDocumentData['document'],
+ 'fieldset' => $this->fieldset,
+ 'fieldset_values' => $fieldset_values,
);
- return $oTemplate->render($aTemplateData);
- }
-
+ return $oTemplate->render($aTemplateData);
+ }
+
function renderEdit($document_data) {
global $main; // FIXME remove direct access to $main
-
+
$aFields = array();
-
+
$fields =& $this->fieldset->getFields();
-
+
foreach ($fields as $oField) {
- $val = KTUtil::arrayGet($document_data["field_values"], $oField->getId(), null);
-
+ $val = KTUtil::arrayGet($document_data['field_values'], $oField->getId(), null);
+
$has_errors = KTUtil::arrayGet($document_data['errors'], $oField->getId(),false);
if ($has_errors !== false) {
// FIXME when the actual errors (meaningful) are passed out, fix this.
$errors = array(_kt('The system rejected your value for this field.'));
- } else {
+ } else {
$errors = null;
}
-
+
$aFields[] = getWidgetForMetadataField($oField, $val, $main, $errors); // FIXME handle errors
}
$fieldset_name = $this->fieldset->getName();
$fieldset_description = $this->fieldset->getDescription();
- $oTemplating =& KTTemplating::getSingleton();
- $oTemplate = $oTemplating->loadTemplate("kt3/fieldsets/simple_editable");
+ $oTemplating =& KTTemplating::getSingleton();
+ $oTemplate = $oTemplating->loadTemplate('kt3/fieldsets/simple_editable');
$aTemplateData = array(
- "context" => $this,
- "fields" => $aFields,
- "title" => $fieldset_name,
- "description" => $fieldset_description,
+ 'context' => $this,
+ 'fields' => $aFields,
+ 'title' => $fieldset_name,
+ 'description' => $fieldset_description,
);
-
-
+
+
return $oTemplate->render($aTemplateData);
}
-
+
}
// Handle the conditional case.
class ConditionalFieldsetDisplay extends SimpleFieldsetDisplay {
-
+
function renderEdit($document_data) {
global $main; // FIXME remove direct access to $main
$oPage =& $main;
-
+
// FIXME do this from inside the widgetry mojo.
$oPage->requireCSSResource('resources/css/kt-treewidget.css');
-
+
// FIXME this currently doesn't work, since we use NBM's half-baked Ajax on add/bulk ;)
$oPage->requireJSResource('resources/js/taillog.js');
$oPage->requireJSResource('resources/js/conditional_usage.js');
-
- $aFields = array();
+
+ $aFields = array();
$fields =& $this->fieldset->getFields();
$values = array();
$errors = $document_data['errors'];
$have_values = false;
foreach ($fields as $oField) {
- $val = KTUtil::arrayGet($document_data["field_values"], $oField->getId(), null);
+ $val = KTUtil::arrayGet($document_data['field_values'], $oField->getId(), null);
if ($val !== null) {
$have_values = true;
-
- }
-
+
+ }
+
$values[$oField->getId()] = $val;
- }
+ }
+
-
// now, we need to do some extra work on conditional widgets.
// how?
-
+
$fieldset_name = $this->fieldset->getName();
$fieldset_description = _kt($this->fieldset->getDescription()); // need a better approach. how do we handle database-resident translations?
- $fieldset_description .= _kt("Note that the options which are available depends on previous choices within this fieldset.");
-
+ $fieldset_description .= _kt('Note that the options which are available depends on previous choices within this fieldset.');
+
// FIXME handle the editable case _with_ values.
-
+
if ($have_values) {
- $oTemplating =& KTTemplating::getSingleton();
- $oTemplate = $oTemplating->loadTemplate("kt3/fieldsets/conditional_editable_values");
+ $oTemplating =& KTTemplating::getSingleton();
+ $oTemplate = $oTemplating->loadTemplate('kt3/fieldsets/conditional_editable_values');
$aTemplateData = array(
- "context" => $this,
- "fields" => $fields =& $this->fieldset->getFields(),
+ 'context' => $this,
+ 'fields' => $fields =& $this->fieldset->getFields(),
'fieldset_id' => $this->fieldset->getId(),
- "title" => $fieldset_name,
- "description" => $fieldset_description,
+ 'title' => $fieldset_name,
+ 'description' => $fieldset_description,
'values' => $values,
'errors' => $errors,
);
-
+
return $oTemplate->render($aTemplateData);
} // else {
-
- $oTemplating =& KTTemplating::getSingleton();
- $oTemplate = $oTemplating->loadTemplate("kt3/fieldsets/conditional_editable");
+
+ $oTemplating =& KTTemplating::getSingleton();
+ $oTemplate = $oTemplating->loadTemplate('kt3/fieldsets/conditional_editable');
$aTemplateData = array(
- "context" => $this,
- "field" => $oField, // first field, widget.
+ 'context' => $this,
+ 'field' => $oField, // first field, widget.
'fieldset_id' => $this->fieldset->getId(),
- "title" => $fieldset_name,
- "description" => $fieldset_description,
+ 'title' => $fieldset_name,
+ 'description' => $fieldset_description,
);
-
+
return $oTemplate->render($aTemplateData);
}
-
+
}
-?>
+?>
\ No newline at end of file
diff --git a/plugins/housekeeper/DiskUsageDashlet.inc.php b/plugins/housekeeper/DiskUsageDashlet.inc.php
index ca7f13c..e1a2d86 100644
--- a/plugins/housekeeper/DiskUsageDashlet.inc.php
+++ b/plugins/housekeeper/DiskUsageDashlet.inc.php
@@ -1,7 +1,7 @@
= 100 - $this->urgentPercent)
{
$colour = 'red';
@@ -114,6 +116,10 @@ class DiskUsageDashlet extends KTBaseDashlet
{
$colour = 'orange';
}
+ elseif ( $usedp < 100 - $this->warningPercent)
+ {
+ $colour = 'none';
+ }
$usage[] = array(
'filesystem'=>$filesystem,
diff --git a/plugins/housekeeper/FolderUsageDashlet.inc.php b/plugins/housekeeper/FolderUsageDashlet.inc.php
index c8ebb4b..d8644e3 100644
--- a/plugins/housekeeper/FolderUsageDashlet.inc.php
+++ b/plugins/housekeeper/FolderUsageDashlet.inc.php
@@ -1,37 +1,37 @@
.
- *
+ *
* You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
* Blake Street, Observatory, 7925 South Africa. 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
- * copyright notice.
+ * must display the words "Powered by KnowledgeTree" and retain the original
+ * copyright notice.
* Contributor( s): ______________________________________
*/
@@ -55,7 +55,7 @@ class FolderUsageDashlet extends KTBaseDashlet
$files=0;
$filesize=0;
- if ($dh = opendir($path))
+ if (is_dir($path) && ($dh = opendir($path)))
{
while (($file = readdir($dh)) !== false)
{
@@ -131,7 +131,7 @@ class FolderUsageDashlet extends KTBaseDashlet
'description'=>$name,
'folder'=>$directory,
'files'=>number_format($temp['files'],0,'.',','),
- 'filesize'=>KTUtil::filesizeToString($temp['filesize']),
+ 'filesize'=>KTUtil::filesizeToString($temp['filesize']/1024),
'action'=>$i,
'canClean'=>$canClean
);
diff --git a/plugins/ktcore/KTBulkActions.php b/plugins/ktcore/KTBulkActions.php
index e2d53fa..d8d84f3 100644
--- a/plugins/ktcore/KTBulkActions.php
+++ b/plugins/ktcore/KTBulkActions.php
@@ -661,6 +661,9 @@ class KTBrowseBulkExportAction extends KTBulkAction {
parent_folder_ids LIKE '%,{$sFolderId}'";
$aFolderList = $this->oFolder->getList($sWhereClause);
+ $aFolderObjects = array();
+ $aFolderObjects[$sFolderId] = $oFolder;
+
// Export the folder structure to ensure the export of empty directories
if(!empty($aFolderList)){
foreach($aFolderList as $k => $oFolderItem){
@@ -673,6 +676,7 @@ class KTBrowseBulkExportAction extends KTBulkAction {
$aDocuments = array_merge($aDocuments, $aFolderDocs);
}
$this->oZip->addFolderToZip($oFolderItem);
+ $aFolderObjects[$oFolderItem->getId()] = $oFolderItem;
}
}
@@ -680,6 +684,8 @@ class KTBrowseBulkExportAction extends KTBulkAction {
if(!empty($aDocuments)){
foreach($aDocuments as $sDocumentId){
$oDocument = Document::get($sDocumentId);
+ $sDocFolderId = $oDocument->getFolderID();
+ $oFolder = isset($aFolderObjects[$sDocFolderId]) ? $aFolderObjects[$sDocFolderId] : Folder::get($sDocFolderId);
if ($this->bNoisy) {
$oDocumentTransaction = new DocumentTransaction($oDocument, "Document part of bulk export", 'ktstandard.transactions.bulk_export', array());
@@ -689,11 +695,10 @@ class KTBrowseBulkExportAction extends KTBulkAction {
// fire subscription alerts for the downloaded document
if($this->bNotifications){
$oSubscriptionEvent = new SubscriptionEvent();
- $oFolder = Folder::get($oDocument->getFolderID());
$oSubscriptionEvent->DownloadDocument($oDocument, $oFolder);
}
- $this->oZip->addDocumentToZip($oDocument);
+ $this->oZip->addDocumentToZip($oDocument, $oFolder);
}
}
}
@@ -906,6 +911,9 @@ class KTBrowseBulkCheckoutAction extends KTBulkAction {
parent_folder_ids LIKE '%,{$sFolderId}'";
$aFolderList = $this->oFolder->getList($sWhereClause);
+ $aFolderObjects = array();
+ $aFolderObjects[$sFolderId] = $oFolder;
+
// Get the documents within the folder
if(!empty($aFolderList)){
foreach($aFolderList as $k => $oFolderItem){
@@ -921,6 +929,7 @@ class KTBrowseBulkCheckoutAction extends KTBulkAction {
// Add the folder to the zip file
if($this->bDownload){
$this->oZip->addFolderToZip($oFolderItem);
+ $aFolderObjects[$oFolderItem->getId()] = $oFolderItem;
}
}
}
@@ -961,7 +970,9 @@ class KTBrowseBulkCheckoutAction extends KTBulkAction {
$oDocumentTransaction = new DocumentTransaction($oDocument, "Document part of bulk checkout", 'ktstandard.transactions.check_out', array());
$oDocumentTransaction->create();
}
- $this->oZip->addDocumentToZip($oDocument);
+ $sDocFolderId = $oDocument->getFolderID();
+ $oFolder = isset($aFolderObjects[$sDocFolderId]) ? $aFolderObjects[$sDocFolderId] : Folder::get($sDocFolderId);
+ $this->oZip->addDocumentToZip($oDocument, $oFolder);
}
}
}
diff --git a/plugins/ktcore/KTCorePlugin.php b/plugins/ktcore/KTCorePlugin.php
index 4463575..289c5d0 100644
--- a/plugins/ktcore/KTCorePlugin.php
+++ b/plugins/ktcore/KTCorePlugin.php
@@ -158,6 +158,11 @@ class KTCorePlugin extends KTPlugin {
$this->registerTrigger('edit', 'postValidate', 'SavedSearchSubscriptionTrigger', 'ktcore.search2.savedsearch.subscription.edit', KT_DIR . '/plugins/search2/Search2Triggers.php');
$this->registerTrigger('add', 'postValidate', 'SavedSearchSubscriptionTrigger', 'ktcore.search2.savedsearch.subscription.add', KT_DIR . '/plugins/search2/Search2Triggers.php');
$this->registerTrigger('discussion', 'postValidate', 'SavedSearchSubscriptionTrigger', 'ktcore.search2.savedsearch.subscription.discussion', KT_DIR . '/plugins/search2/Search2Triggers.php');
+
+ //Tag Cloud Triggers
+ $this->registerTrigger('add', 'postValidate', 'KTAddDocumentTrigger', 'ktcore.triggers.tagcloud.add', KT_DIR.'/plugins/tagcloud/TagCloudTriggers.php');
+ $this->registerTrigger('edit', 'postValidate', 'KTEditDocumentTrigger', 'ktcore.triggers.tagcloud.edit', KT_DIR.'/plugins/tagcloud/TagCloudTriggers.php');
+
// widgets
$this->registerWidget('KTCoreHiddenWidget', 'ktcore.widgets.hidden', 'KTWidgets.php');
diff --git a/plugins/ktcore/admin/documentFieldsv2.php b/plugins/ktcore/admin/documentFieldsv2.php
index 99041e3..bb1e149 100644
--- a/plugins/ktcore/admin/documentFieldsv2.php
+++ b/plugins/ktcore/admin/documentFieldsv2.php
@@ -66,7 +66,7 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher {
$oTemplate->setData(array(
'context' => $this,
- 'fieldsets' => KTFieldset::getList('disabled != true'),
+ 'fieldsets' => KTFieldset::getList("disabled != true AND namespace != 'tagcloud'"),
));
return $oTemplate;
}
diff --git a/plugins/ktcore/admin/plugins.php b/plugins/ktcore/admin/plugins.php
index 162684f..8bc4231 100755
--- a/plugins/ktcore/admin/plugins.php
+++ b/plugins/ktcore/admin/plugins.php
@@ -75,6 +75,33 @@ class KTPluginDispatcher extends KTAdminDispatcher {
$sTable = KTUtil::getTableName('plugins');
$aIds = (array) KTUtil::arrayGet($_REQUEST, 'pluginids');
KTPluginEntity::setEnabled($aIds);
+ //enabling or disabling Tag fieldset depending on whether tag cloud plugin is enabled or disabled.
+ //Get tag cloud object
+ $oTagClouPlugin = KTPluginEntity::getByNamespace('ktcore.tagcloud.plugin');
+ if($oTagClouPlugin->getDisabled() == '1')
+ {
+ //disable tag fieldset
+ $aFV = array(
+ 'disabled' => true,
+ );
+ $aWFV = array(
+ 'namespace' => 'tagcloud'
+ );
+ $res = DBUtil::whereUpdate('fieldsets', $aFV, $aWFV);
+ }
+ //if Tag Cloud plugin disabled
+ if($oTagClouPlugin->getDisabled() == '0')
+ {
+ //enable tag fieldset
+ $aFV = array(
+ 'disabled' => false,
+ );
+ $aWFV = array(
+ 'namespace' => 'tagcloud'
+ );
+ $res = DBUtil::whereUpdate('fieldsets', $aFV, $aWFV);
+ }
+
$this->successRedirectToMain(_kt('Plugins updated'));
}
diff --git a/plugins/ktcore/document/edit.php b/plugins/ktcore/document/edit.php
index 2a5615b..419d4df 100644
--- a/plugins/ktcore/document/edit.php
+++ b/plugins/ktcore/document/edit.php
@@ -4,32 +4,32 @@
* KnowledgeTree Open Source Edition
* Document Management Made Simple
* Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited
- *
+ *
* 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 The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
* Blake Street, Observatory, 7925 South Africa. 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
- * copyright notice.
+ * must display the words "Powered by KnowledgeTree" and retain the original
+ * copyright notice.
* Contributor( s): ______________________________________
*
*/
@@ -198,6 +198,10 @@ class KTDocumentEditAction extends KTDocumentAction {
$this->oDocument->setDocumentTypeId($doctypeid);
}
$this->oDocument->setName(($data['document_title']));
+ $this->oDocument->startNewContentVersion($this->oUser);
+ $this->oDocument->setMinorVersionNumber($this->oDocument->getMinorVersionNumber()+1);
+ $this->oDocument->setLastModifiedDate(getCurrentDateTime());
+ $this->oDocument->setModifiedUserId($this->oUser->getId());
$res = $this->oDocument->update();
if (PEAR::isError($res)) {
diff --git a/plugins/ktcore/folder/BulkImport.php b/plugins/ktcore/folder/BulkImport.php
index bc80c8d..74ba7fa 100644
--- a/plugins/ktcore/folder/BulkImport.php
+++ b/plugins/ktcore/folder/BulkImport.php
@@ -5,32 +5,32 @@
* KnowledgeTree Open Source Edition
* Document Management Made Simple
* Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited
- *
+ *
* 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 The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
* Blake Street, Observatory, 7925 South Africa. 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
- * copyright notice.
+ * must display the words "Powered by KnowledgeTree" and retain the original
+ * copyright notice.
* Contributor( s): ______________________________________
*
*/
@@ -60,7 +60,7 @@ class KTBulkImportFolderAction extends KTFolderAction {
function getInfo() {
if (!Permission::userIsSystemAdministrator($this->oUser->getId())) {
return null;
-
+
}
return parent::getInfo();
}
@@ -122,6 +122,7 @@ class KTBulkImportFolderAction extends KTFolderAction {
$aOptions = array(
'documenttype' => $oDocumentType,
'metadata' => $aFields,
+ 'copy_upload' => 'true',
);
$po =& new JavascriptObserver($this);
diff --git a/plugins/ktcore/folder/BulkUpload.php b/plugins/ktcore/folder/BulkUpload.php
index 9f6ce32..f3f29e6 100644
--- a/plugins/ktcore/folder/BulkUpload.php
+++ b/plugins/ktcore/folder/BulkUpload.php
@@ -114,7 +114,16 @@ class KTBulkUploadFolderAction extends KTFolderAction {
unset($aErrorOptions['message']);
$aFile = $this->oValidator->validateFile($_FILES['file'], $aErrorOptions);
-
+
+ // Ensure file is a zip file
+ $sMime = $aFile['type'];
+ $pos = strpos($sMime, 'x-zip-compressed');
+ if($pos === false){
+ $this->addErrorMessage(_kt("Bulk Upload failed: File is not a zip file."));
+ controllerRedirect("browse", 'fFolderId=' . $this->oFolder->getID());
+ exit(0);
+ }
+
$matches = array();
$aFields = array();
foreach ($_REQUEST as $k => $v) {
@@ -132,6 +141,7 @@ class KTBulkUploadFolderAction extends KTFolderAction {
$bm =& new KTBulkImportManager($this->oFolder, $fs, $this->oUser, $aOptions);
$this->startTransaction();
$res = $bm->import();
+
$aErrorOptions['message'] = _kt("Bulk Upload failed");
$this->oValidator->notError($res, $aErrorOptions);
diff --git a/plugins/ktcore/folder/Permissions.php b/plugins/ktcore/folder/Permissions.php
index d7af65a..7ca2fbc 100644
--- a/plugins/ktcore/folder/Permissions.php
+++ b/plugins/ktcore/folder/Permissions.php
@@ -1,36 +1,36 @@
.
- *
+ *
* You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
* Blake Street, Observatory, 7925 South Africa. 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
- * copyright notice.
+ * must display the words "Powered by KnowledgeTree" and retain the original
+ * copyright notice.
* Contributor( s): ______________________________________
*/
@@ -141,22 +141,22 @@ class KTFolderPermissionsAction extends KTFolderAction {
$sInherited = join(' > ', $oInherited->getPathArray());
}
// only allow inheritance if not inherited, -and- folders is editable
- $bInheritable = $bEdit && ($oInherited->getId() !== $this->oFolder->getId());
+ $bInheritable = $bEdit && ($oInherited->getId() !== $this->oFolder->getId());
// only allow edit if the folder is editable.
$bEdit = $bEdit && ($oInherited->getId() == $this->oFolder->getId());
-
+
$aConditions = array();
$aDynConditions = KTPermissionDynamicCondition::getByPermissionObject($oPO);
-
+
foreach ($aDynConditions as $oDynCondition) {
$g = Group::get($oDynCondition->getGroupId());
if (is_null($g)) continue; // db integrity catch
-
+
if (PEAR::isError($g)) { continue; }
- $c = KTSavedSearch::get($oDynCondition->getConditionId());
- if (is_null($c)) continue; // db integrity catch
+ $c = KTSavedSearch::get($oDynCondition->getConditionId());
+ if (is_null($c)) continue; // db integrity catch
if (PEAR::isError($c)) { continue; }
-
+
$aInfo = array(
'group' => $g->getName(),
'name' => $c->getName(),
@@ -183,7 +183,7 @@ class KTFolderPermissionsAction extends KTFolderAction {
'edit' => $bEdit,
'inheritable' => $bInheritable,
'inherited' => $sInherited,
- 'conditions' => $aConditions,
+ 'conditions' => $aConditions,
);
return $oTemplate->render($aTemplateData);
}
@@ -206,15 +206,20 @@ class KTFolderPermissionsAction extends KTFolderAction {
if (PEAR::isError($oPLA)) {
continue;
}
- $oDescriptor = KTPermissionDescriptor::get($oPLA->getPermissionDescriptorID());
+ $oDescriptor =& KTPermissionDescriptor::get($oPLA->getPermissionDescriptorID());
$iPermissionID = $oPermission->getID();
$aMapPermissionGroup[$iPermissionID] = array();
- foreach ($aUsers as $oUser) {
- if (KTPermissionUtil::userHasPermissionOnItem($oUser, $oPermission, $this->oFolder)) {
- $aMapPermissionUser[$iPermissionID][$oUser->getId()] = true;
- $aActiveUsers[$oUser->getId()] = true;
- }
- }
+
+ $hasPermission = false;
+ $everyone = $oDescriptor->hasRoles(array(-3));
+ $authenticated = $oDescriptor->hasRoles(array(-4));
+ // TODO : paginate this page, when there are too many users
+ foreach ($aUsers as $oUser) {
+ if ($everyone || ($authenticated && $oUser->isAnonymous()) ||
+ $oUser->hasPermission($oDescriptor)) {
+ $aMapPermissionUser[$iPermissionID][$oUser->getId()] = true;
+ }
+ }
}
// now we constitute the actual sets.
@@ -222,12 +227,7 @@ class KTFolderPermissionsAction extends KTFolderAction {
$groups = array();
$roles = array(); // should _always_ be empty, barring a bug in permissions::updatePermissionLookup
- // this should be quite limited - direct role -> user assignment is typically rare.
- foreach ($aActiveUsers as $id => $marker) {
- $oUser = User::get($id);
- if (is_null($oUser)) continue;
- $users[$oUser->getName()] = $oUser;
- }
+ $users = $aUsers;
asort($users); // ascending, per convention.
$bEdit = false;
@@ -245,23 +245,12 @@ class KTFolderPermissionsAction extends KTFolderAction {
'aMapPermissionUser' => $aMapPermissionUser,
'edit' => $bEdit,
'inherited' => $sInherited,
- 'foldername' => $this->oFolder->getName(),
- 'iFolderId' => $this->oFolder->getId(),
+ 'foldername' => $this->oFolder->getName(),
+ 'iFolderId' => $this->oFolder->getId(),
);
return $oTemplate->render($aTemplateData);
}
-
-
-
-
-
-
-
-
-
-
-
function _copyPermissions() {
$oTransaction = KTFolderTransaction::createFromArray(array(
'folderid' => $this->oFolder->getId(),
@@ -295,13 +284,13 @@ class KTFolderPermissionsAction extends KTFolderAction {
$oInherited = KTPermissionUtil::findRootObjectForPermissionObject($oPO);
if ($oInherited->getId() !== $this->oFolder->getId()) {
$override = KTUtil::arrayGet($_REQUEST, 'override', false);
- if (empty($override)) {
+ if (empty($override)) {
$this->errorRedirectToMain(_kt('This folder does not override its permissions'), sprintf('fFolderId=%d', $this->oFolder->getId()));
}
$this->startTransaction();
$this->_copyPermissions();
$this->commitTransaction();
- $oPO = KTPermissionObject::get($this->oFolder->getPermissionObjectId());
+ $oPO = KTPermissionObject::get($this->oFolder->getPermissionObjectId());
}
@@ -325,15 +314,15 @@ class KTFolderPermissionsAction extends KTFolderAction {
$perms = KTPermission::getList();
$docperms = KTPermission::getDocumentRelevantList();
-
- $aTemplateData = array(
+
+ $aTemplateData = array(
'iFolderId' => $this->oFolder->getId(),
'roles' => Role::getList(),
'groups' => Group::getList(),
'conditions' => KTSavedSearch::getConditions(),
'dynamic_conditions' => $aDynamicConditions,
'context' => &$this,
- 'foldername' => $this->oFolder->getName(),
+ 'foldername' => $this->oFolder->getName(),
'jsonpermissions' => $sJSONPermissions,
'edit' => true,
'permissions' => $perms,
@@ -374,7 +363,7 @@ class KTFolderPermissionsAction extends KTFolderAction {
$aRoleIds = $oDescriptor->getRoles();
foreach ($aRoleIds as $iId) {
$aPermissionsMap['role'][$iId][$iPermissionId] = true;
- }
+ }
}
return $aPermissionsMap;
}
@@ -427,7 +416,7 @@ class KTFolderPermissionsAction extends KTFolderAction {
'name' => $oGroup->getName(),
'permissions' => $aPerm,
'id' => $oGroup->getId());
- }
+ }
}
$aRoles = Role::getList(sprintf('name like \'%%%s%%\'', $sFilter));
@@ -436,9 +425,9 @@ class KTFolderPermissionsAction extends KTFolderAction {
if(!is_array($aPerm)) {
$aPerm = array();
}
-
+
if($bSelected) {
- if(count($aPerm))
+ if(count($aPerm))
$aEntityList['r'.$oRole->getId()] = array('type' => 'role',
'display' => _kt('Role') . ': ' . $oRole->getName(),
'name' => $oRole->getName(),
@@ -453,7 +442,7 @@ class KTFolderPermissionsAction extends KTFolderAction {
'id' => $oRole->getId());
}
}
- }
+ }
return $aEntityList;
}
diff --git a/plugins/ktcore/folder/addDocument.php b/plugins/ktcore/folder/addDocument.php
index 83e6869..bbaac75 100644
--- a/plugins/ktcore/folder/addDocument.php
+++ b/plugins/ktcore/folder/addDocument.php
@@ -324,7 +324,7 @@ class KTFolderAddDocumentAction extends KTFolderAction {
);
$mpo->start();
- $this->startTransaction();
+ //$this->startTransaction();
$oDocument =& KTDocumentUtil::add($this->oFolder, basename($aFile['name']), $this->oUser, $aOptions);
if (PEAR::isError($oDocument)) {
$message = $oDocument->getMessage();
@@ -333,7 +333,7 @@ class KTFolderAddDocumentAction extends KTFolderAction {
}
$this->addInfoMessage(_kt("Document added"));
- $this->commitTransaction();
+ //$this->commitTransaction();
$mpo->redirectToDocument($oDocument->getId());
exit(0);
diff --git a/plugins/ktstandard/KTBulkExportPlugin.php b/plugins/ktstandard/KTBulkExportPlugin.php
index ad78a59..8207a01 100644
--- a/plugins/ktstandard/KTBulkExportPlugin.php
+++ b/plugins/ktstandard/KTBulkExportPlugin.php
@@ -5,32 +5,32 @@
* KnowledgeTree Open Source Edition
* Document Management Made Simple
* Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited
- *
+ *
* 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 The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
* Blake Street, Observatory, 7925 South Africa. 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
- * copyright notice.
+ * must display the words "Powered by KnowledgeTree" and retain the original
+ * copyright notice.
* Contributor( s): ______________________________________
*
*/
@@ -109,9 +109,24 @@ class KTBulkExportAction extends KTFolderAction {
$this->oPage->template = "kt3/minimal_page";
$this->handleOutput("");
+ // Create associative array of folder items for use by the contained documents
+ $aFolderObjects = array();
+ $aFolderObjects[$sCurrentFolderId] = $this->oFolder;
+
+ // Export the folder structure to ensure the export of empty directories
+ if(!empty($aFolderList)){
+ foreach($aFolderList as $k => $oFolderItem){
+ $this->oZip->addFolderToZip($oFolderItem);
+ $aFolderObjects[$oFolderItem->getId()] = $oFolderItem;
+ }
+ }
+
if(!empty($aDocumentIds)){
foreach ($aDocumentIds as $iId) {
$oDocument = Document::get($iId);
+ $sFolderId = $oDocument->getFolderID();
+
+ $oFolder = isset($aFolderObjects[$sFolderId]) ? $aFolderObjects[$sFolderId] : Folder::get($sFolderId);
if ($bNoisy) {
$oDocumentTransaction = & new DocumentTransaction($oDocument, "Document part of bulk export", 'ktstandard.transactions.bulk_export', array());
@@ -121,19 +136,13 @@ class KTBulkExportAction extends KTFolderAction {
// fire subscription alerts for the downloaded document
if($bNotifications){
$oSubscriptionEvent = new SubscriptionEvent();
- $oFolder = Folder::get($oDocument->getFolderID());
$oSubscriptionEvent->DownloadDocument($oDocument, $oFolder);
}
- $this->oZip->addDocumentToZip($oDocument);
+ $this->oZip->addDocumentToZip($oDocument, $oFolder);
}
}
- // Export the folder structure to ensure the export of empty directories
- foreach($aFolderList as $k => $oFolderItem){
- $this->oZip->addFolderToZip($oFolderItem);
- }
-
$sExportCode = $this->oZip->createZipFile(TRUE);
$oTransaction = KTFolderTransaction::createFromArray(array(
@@ -168,7 +177,7 @@ class KTBulkExportAction extends KTFolderAction {
return $res;
}
list($sPermissionString, $aPermissionParams, $sPermissionJoin) = $res;
- $aPotentialWhere = array($sPermissionString, 'D.parent_folder_ids = ? OR D.parent_folder_ids LIKE ?', 'D.status_id = 1');
+ $aPotentialWhere = array($sPermissionString, 'D.folder_id = ? OR D.parent_folder_ids = ? OR D.parent_folder_ids LIKE ?', 'D.status_id = 1');
$aWhere = array();
foreach ($aPotentialWhere as $sWhere) {
if (empty($sWhere)) {
@@ -202,6 +211,7 @@ class KTBulkExportAction extends KTFolderAction {
array_shift($aParentFolderIds);
}
$sParentFolderIds = join(',', $aParentFolderIds);
+ $aParams[] = $this->oFolder->getId();
$aParams[] = $sParentFolderIds;
$aParams[] = $sParentFolderIds . ",%";
return array($sQuery, $aParams);
diff --git a/plugins/search2/LuceneStatisticsDashlet.php b/plugins/search2/LuceneStatisticsDashlet.php
index 91f94d8..3cec0de 100644
--- a/plugins/search2/LuceneStatisticsDashlet.php
+++ b/plugins/search2/LuceneStatisticsDashlet.php
@@ -6,32 +6,32 @@
* KnowledgeTree Open Source Edition
* Document Management Made Simple
* Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited
- *
+ *
* 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 The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
* Blake Street, Observatory, 7925 South Africa. 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
- * copyright notice.
+ * must display the words "Powered by KnowledgeTree" and retain the original
+ * copyright notice.
* Contributor( s): ______________________________________
*
*/
@@ -100,7 +100,8 @@ class LuceneStatisticsDashlet extends KTBaseDashlet
$index = Indexer::get();
$docsInIndex = $index->getDocumentsInIndex();
- $sql = "SELECT count(*) as docsInQueue FROM index_files";
+ // we are only interested in documents that are active
+ $sql = "SELECT count(*) as docsInQueue FROM index_files q INNER JOIN documents d on q.document_id=d.id WHERE d.status_id=1";
$docsInQueue = DBUtil::getOneResultKey($sql, 'docsInQueue');
$sql = "SELECT count(*) as docsInRepository FROM documents";
diff --git a/plugins/tagcloud/TagCloudDashlet.php b/plugins/tagcloud/TagCloudDashlet.php
index 4c768fd..08597cb 100644
--- a/plugins/tagcloud/TagCloudDashlet.php
+++ b/plugins/tagcloud/TagCloudDashlet.php
@@ -1,7 +1,7 @@
oUser, null);
-
$sql = "
SELECT
TW.tag, count(*) as freq
FROM
document_tags DT INNER JOIN tag_words TW ON DT.tag_id=TW.id
- WHERE DT.document_id in (SELECT D.id FROM documents D $joins WHERE $where) GROUP BY TW.tag";
+ WHERE DT.document_id in (SELECT D.id FROM documents D $joins WHERE $where AND D.status_id = '1') GROUP BY TW.tag";
$tags = DBUtil::getResultArray(
array($sql,$params)
diff --git a/plugins/tagcloud/TagCloudPlugin.php b/plugins/tagcloud/TagCloudPlugin.php
index 1cd9b26..038fe00 100644
--- a/plugins/tagcloud/TagCloudPlugin.php
+++ b/plugins/tagcloud/TagCloudPlugin.php
@@ -1,7 +1,7 @@
registerCriterion('TagCloudCriterion', 'ktcore.criteria.tagcloud', KT_LIB_DIR . '/browse/Criteria.inc');
$this->registerDashlet('TagCloudDashlet', 'ktcore.tagcloud.feed.dashlet', 'TagCloudDashlet.php');
$this->registerPage('TagCloudRedirection', 'TagCloudRedirectPage', __FILE__);
- $this->registerTrigger('add', 'postValidate', 'KTAddDocumentTrigger',
- 'ktcore.triggers.tagcloud.add');
- $this->registerTrigger('edit', 'postValidate', 'KTEditDocumentTrigger',
- 'ktcore.triggers.tagcloud.edit');
+
// Check if the tagcloud fielset entry exists, if not, create it
if(!TagCloudPlugin::tagFieldsetExists()){
@@ -192,213 +189,4 @@ require_once(KT_LIB_DIR . '/templating/templating.inc.php');
$oPluginRegistry =& KTPluginRegistry::getSingleton();
$oPluginRegistry->registerPlugin('TagCloudPlugin', 'ktcore.tagcloud.plugin', __FILE__);
-/**
- * Trigger for document add (postValidate)
- *
- */
-class KTAddDocumentTrigger {
- var $aInfo = null;
- /**
- * function to set the info for the trigger
- *
- * @param array $aInfo
- */
- function setInfo(&$aInfo) {
- $this->aInfo =& $aInfo;
- }
-
- /**
- * postValidate method for trigger
- *
- * @return unknown
- */
- function postValidate() {
- global $default;
- $oDocument =& $this->aInfo['document'];
- $aMeta = & $this->aInfo['aOptions'];
-
- $iDocId = $oDocument->getID();
-
- // get tag id from document_fields table where name = Tag
- $sQuery = 'SELECT df.id AS id FROM document_fields AS df ' .
- 'WHERE df.name = \'Tag\'';
-
- $sTags = DBUtil::getOneResultKey(array($sQuery), 'id');
- if (PEAR::isError($sTags)) {
- // XXX: log error
- return false;
- }
- $tagString = '';
- // add tags
- if ($sTags) {
- if (count($aMeta['metadata']) > 0)
- {
- foreach($aMeta['metadata'] as $aMetaData)
- {
-
- $oProxy = $aMetaData[0];
- if($oProxy->iId == $sTags)
- {
- $tagString = $aMetaData[1];
- }
- }
- }
- if($tagString != ''){
- $words_table = KTUtil::getTableName('tag_words');
- $tagString = str_replace(' ', '', $tagString);
- $tags = explode(',',$tagString);
-
- $aTagIds = array();
-
- foreach($tags as $sTag)
- {
- $sTag=strtolower(trim($sTag));
-
- $res = DBUtil::getOneResult(array("SELECT id FROM $words_table WHERE tag = ?", array($sTag)));
-
- if (PEAR::isError($res)) {
- return $res;
- }
-
- if (is_null($res))
- {
- $id = & DBUtil::autoInsert($words_table, array('tag'=>$sTag));
- $aTagIds[$sTag] = $id;
- }
- else
- {
- $aTagIds[$sTag] = $res['id'];
- }
- }
-
- $doc_tags = KTUtil::getTableName('document_tags');
-
- foreach($aTagIds as $sTag=>$tagid)
- {
- DBUtil::autoInsert($doc_tags, array(
-
- 'document_id'=>$iDocId,
- 'tag_id'=>$tagid),
- array('noid'=>true));
- }
- }
- }
- }
-}
-
-/**
- * Trigger for document edit (postValidate)
- *
- */
-class KTEditDocumentTrigger {
- var $aInfo = null;
- /**
- * function to set the info for the trigger
- *
- * @param array $aInfo
- */
- function setInfo(&$aInfo) {
- $this->aInfo =& $aInfo;
- }
-
- /**
- * postValidate method for trigger
- *
- * @return unknown
- */
- function postValidate() {
- global $default;
- $oDocument =& $this->aInfo['document'];
- $aMeta = & $this->aInfo['aOptions'];
- // get document id
- $iDocId = $oDocument->getID();
-
- // get all tags that are linked to the document
- $sQuery = 'SELECT tw.id FROM tag_words AS tw, document_tags AS dt, documents AS d ' .
- 'WHERE dt.tag_id = tw.id ' .
- 'AND dt.document_id = d.id ' .
- 'AND d.id = ?';
- $aParams = array($iDocId);
- $aTagId = DBUtil::getResultArray(array($sQuery, $aParams));
- if (PEAR::isError($aTagId)) {
- // XXX: log error
- return false;
- }
- // if there are any related tags proceed
- if ($aTagId) {
- // delete all entries from document_tags table for the document
- $sQuery = 'DELETE FROM document_tags ' .
- 'WHERE document_id = ?';
- $aParams = array($iDocId);
- $removed = DBUtil::runQuery(array($sQuery, $aParams));
- if (PEAR::isError($removed)) {
- // XXX: log error
- return false;
- }
- }
- // proceed to add the tags as per normaly
- $sQuery = 'SELECT df.id AS id FROM document_fields AS df ' .
- 'WHERE df.name = \'Tag\'';
-
- $sTags = DBUtil::getOneResultKey(array($sQuery), 'id');
- if (PEAR::isError($sTags)) {
- // XXX: log error
- return false;
- }
- $tagString = '';
- if ($sTags) {
- // it is actually correct using $aMeta. It is different to the add trigger above...
- if (count($aMeta) > 0)
- {
- foreach($aMeta as $aMetaData)
- {
- $oProxy = $aMetaData[0];
- if($oProxy->iId == $sTags)
- {
- $tagString = $aMetaData[1];
- break;
- }
- }
- }
- if($tagString != ''){
- $words_table = KTUtil::getTableName('tag_words');
- $tagString = str_replace(' ', ' ', $tagString);
- $tags = explode(',',$tagString);
-
- $aTagIds = array();
-
- foreach($tags as $sTag)
- {
- $sTag=strtolower(trim($sTag));
-
- $res = DBUtil::getOneResult(array("SELECT id FROM $words_table WHERE tag = ?", array($sTag)));
-
- if (PEAR::isError($res)) {
- return $res;
- }
-
- if (is_null($res))
- {
- $id = & DBUtil::autoInsert($words_table, array('tag'=>$sTag));
- $aTagIds[$sTag] = $id;
- }
- else
- {
- $aTagIds[$sTag] = $res['id'];
- }
- }
-
- $doc_tags = KTUtil::getTableName('document_tags');
-
- foreach($aTagIds as $sTag=>$tagid)
- {
- DBUtil::autoInsert($doc_tags, array(
- 'document_id'=>$iDocId,
- 'tag_id'=>$tagid),
- array('noid'=>true));
- }
- }
- }
- }
-}
?>
diff --git a/plugins/tagcloud/TagCloudTriggers.php b/plugins/tagcloud/TagCloudTriggers.php
new file mode 100644
index 0000000..47a8124
--- /dev/null
+++ b/plugins/tagcloud/TagCloudTriggers.php
@@ -0,0 +1,247 @@
+.
+ *
+ * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
+ * Blake Street, Observatory, 7925 South Africa. 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
+ * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
+ * must display the words "Powered by KnowledgeTree" and retain the original
+ * copyright notice.
+ * Contributor( s): ______________________________________
+ *
+ */
+/**
+ * Trigger for document add (postValidate)
+ *
+ */
+class KTAddDocumentTrigger {
+ var $aInfo = null;
+ /**
+ * function to set the info for the trigger
+ *
+ * @param array $aInfo
+ */
+ function setInfo(&$aInfo) {
+ $this->aInfo =& $aInfo;
+ }
+
+ /**
+ * postValidate method for trigger
+ *
+ * @return unknown
+ */
+ function postValidate() {
+ global $default;
+ $oDocument =& $this->aInfo['document'];
+ $aMeta = & $this->aInfo['aOptions'];
+
+ $iDocId = $oDocument->getID();
+
+ // get tag id from document_fields table where name = Tag
+ $sQuery = 'SELECT df.id AS id FROM document_fields AS df ' .
+ 'WHERE df.name = \'Tag\'';
+
+ $sTags = DBUtil::getOneResultKey(array($sQuery), 'id');
+ if (PEAR::isError($sTags)) {
+ // XXX: log error
+ return false;
+ }
+ $tagString = '';
+ // add tags
+ if ($sTags) {
+ if (count($aMeta['metadata']) > 0)
+ {
+ foreach($aMeta['metadata'] as $aMetaData)
+ {
+
+ $oProxy = $aMetaData[0];
+ if($oProxy->iId == $sTags)
+ {
+ $tagString = $aMetaData[1];
+ }
+ }
+ }
+ if($tagString != ''){
+ $words_table = KTUtil::getTableName('tag_words');
+ $tagString = str_replace(' ', '', $tagString);
+ $tags = explode(',',$tagString);
+
+ $aTagIds = array();
+
+ foreach($tags as $sTag)
+ {
+ $sTag=strtolower(trim($sTag));
+
+ $res = DBUtil::getOneResult(array("SELECT id FROM $words_table WHERE tag = ?", array($sTag)));
+
+ if (PEAR::isError($res)) {
+ return $res;
+ }
+
+ if (is_null($res))
+ {
+ $id = & DBUtil::autoInsert($words_table, array('tag'=>$sTag));
+ $aTagIds[$sTag] = $id;
+ }
+ else
+ {
+ $aTagIds[$sTag] = $res['id'];
+ }
+ }
+
+ $doc_tags = KTUtil::getTableName('document_tags');
+
+ foreach($aTagIds as $sTag=>$tagid)
+ {
+ DBUtil::autoInsert($doc_tags, array(
+
+ 'document_id'=>$iDocId,
+ 'tag_id'=>$tagid),
+ array('noid'=>true));
+ }
+ }
+ }
+ }
+}
+
+
+/**
+ * Trigger for document edit (postValidate)
+ *
+ */
+class KTEditDocumentTrigger {
+ var $aInfo = null;
+ /**
+ * function to set the info for the trigger
+ *
+ * @param array $aInfo
+ */
+ function setInfo(&$aInfo) {
+ $this->aInfo =& $aInfo;
+ }
+
+ /**
+ * postValidate method for trigger
+ *
+ * @return unknown
+ */
+ function postValidate() {
+ global $default;
+ $oDocument =& $this->aInfo['document'];
+ $aMeta = & $this->aInfo['aOptions'];
+ // get document id
+ $iDocId = $oDocument->getID();
+
+ // get all tags that are linked to the document
+ $sQuery = 'SELECT tw.id FROM tag_words AS tw, document_tags AS dt, documents AS d ' .
+ 'WHERE dt.tag_id = tw.id ' .
+ 'AND dt.document_id = d.id ' .
+ 'AND d.id = ?';
+ $aParams = array($iDocId);
+ $aTagId = DBUtil::getResultArray(array($sQuery, $aParams));
+ if (PEAR::isError($aTagId)) {
+ // XXX: log error
+ return false;
+ }
+ // if there are any related tags proceed
+ if ($aTagId) {
+ // delete all entries from document_tags table for the document
+ $sQuery = 'DELETE FROM document_tags ' .
+ 'WHERE document_id = ?';
+ $aParams = array($iDocId);
+ $removed = DBUtil::runQuery(array($sQuery, $aParams));
+ if (PEAR::isError($removed)) {
+ // XXX: log error
+ return false;
+ }
+ }
+ // proceed to add the tags as per normaly
+ $sQuery = 'SELECT df.id AS id FROM document_fields AS df ' .
+ 'WHERE df.name = \'Tag\'';
+
+ $sTags = DBUtil::getOneResultKey(array($sQuery), 'id');
+ if (PEAR::isError($sTags)) {
+ // XXX: log error
+ return false;
+ }
+ $tagString = '';
+ if ($sTags) {
+ // it is actually correct using $aMeta. It is different to the add trigger above...
+ if (count($aMeta) > 0)
+ {
+ foreach($aMeta as $aMetaData)
+ {
+ $oProxy = $aMetaData[0];
+ if($oProxy->iId == $sTags)
+ {
+ $tagString = $aMetaData[1];
+ break;
+ }
+ }
+ }
+ if($tagString != ''){
+ $words_table = KTUtil::getTableName('tag_words');
+ $tagString = str_replace(' ', ' ', $tagString);
+ $tags = explode(',',$tagString);
+
+ $aTagIds = array();
+
+ foreach($tags as $sTag)
+ {
+ $sTag=strtolower(trim($sTag));
+
+ $res = DBUtil::getOneResult(array("SELECT id FROM $words_table WHERE tag = ?", array($sTag)));
+
+ if (PEAR::isError($res)) {
+ return $res;
+ }
+
+ if (is_null($res))
+ {
+ $id = & DBUtil::autoInsert($words_table, array('tag'=>$sTag));
+ $aTagIds[$sTag] = $id;
+ }
+ else
+ {
+ $aTagIds[$sTag] = $res['id'];
+ }
+ }
+
+ $doc_tags = KTUtil::getTableName('document_tags');
+
+ foreach($aTagIds as $sTag=>$tagid)
+ {
+ DBUtil::autoInsert($doc_tags, array(
+ 'document_id'=>$iDocId,
+ 'tag_id'=>$tagid),
+ array('noid'=>true));
+ }
+ }
+ }
+ }
+}
+?>
\ No newline at end of file
diff --git a/resources/css/error_01.gif b/resources/css/error_01.gif
new file mode 100644
index 0000000..3f7dfbf
--- /dev/null
+++ b/resources/css/error_01.gif
diff --git a/resources/css/errors.css b/resources/css/errors.css
new file mode 100644
index 0000000..f5da2d6
--- /dev/null
+++ b/resources/css/errors.css
@@ -0,0 +1,43 @@
+div#error-container {
+ width: 500px;
+ color: #555;
+ font-size: 11px;
+ font-family: Verdana, Arial, sans-serif;
+}
+div#error-container div {
+ height: 140px;
+}
+div#error-container h1 {
+ font-weight: lighter;
+ font-size: 22px;
+ margin-left: 100px;
+}
+div#error-container p {
+ margin-left: 100px;
+}
+
+ div#acc-error {
+ background: transparent url(error_01.gif) no-repeat top left;
+ }
+ div#acc-suspend {
+ background: transparent url(error_02.gif) no-repeat top left;
+ }
+ div#acc-maint {
+ background: transparent url(error_03.gif) no-repeat top left;
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/search2/indexing/extractorCore.inc.php b/search2/indexing/extractorCore.inc.php
index c153ba6..161142b 100644
--- a/search2/indexing/extractorCore.inc.php
+++ b/search2/indexing/extractorCore.inc.php
@@ -349,8 +349,21 @@ abstract class ExternalDocumentExtractor extends DocumentExtractor
*/
protected function exec($cmd)
{
- $aRet = KTUtil::pexec($cmd);
- return $aRet['ret'] == 0;
+ if (OS_WINDOWS)
+ {
+
+
+ $WshShell = new COM("WScript.Shell");
+ $res = $WshShell->Run($cmd, 0, true);
+
+
+ return $res == 0;
+ }
+ else
+ {
+ $aRet = KTUtil::pexec($cmd);
+ return $aRet['ret'] == 0;
+ }
}
/**
@@ -456,7 +469,8 @@ abstract class ApplicationExtractor extends ExternalDocumentExtractor
{
$sources = array('{source}','{target}');
$target = array($this->sourcefile, $this->targetfile);
- $cmdline = $this->application . ' ' . str_replace($sources,$target, $this->params);
+ $escape = OS_WINDOWS?'"':'\'';
+ $cmdline = $escape . $this->application . $escape . ' ' . str_replace($sources,$target, $this->params);
return $cmdline;
}
diff --git a/search2/indexing/extractors/OOPresentationExtractor.inc.php b/search2/indexing/extractors/OOPresentationExtractor.inc.php
index 7a4a9ec..ea377b3 100644
--- a/search2/indexing/extractors/OOPresentationExtractor.inc.php
+++ b/search2/indexing/extractors/OOPresentationExtractor.inc.php
@@ -56,6 +56,7 @@ class OOPresentationExtractor extends CompositeExtractor
public function getSupportedMimeTypes()
{
return array(
+ 'application/vnd.ms-powerpoint',
'application/vnd.oasis.opendocument.presentation',
'application/vnd.oasis.opendocument.presentation-template',
);
diff --git a/search2/indexing/extractors/OOTextExtractor.inc.php b/search2/indexing/extractors/OOTextExtractor.inc.php
index 67dac55..997e7b9 100644
--- a/search2/indexing/extractors/OOTextExtractor.inc.php
+++ b/search2/indexing/extractors/OOTextExtractor.inc.php
@@ -88,14 +88,16 @@ class OOTextExtractor extends ExternalDocumentExtractor
protected function getCommandLine()
{
- $sourcefile = escapeshellcmd($this->sourcefile);
+ //$sourcefile = escapeshellcmd($this->sourcefile);
+ $sourcefile = ($this->sourcefile);
unlink($this->targetfile);
$this->targetfile .= '.' . $this->targetExtension;
- $targetfile = escapeshellcmd($this->targetfile);
+ //$targetfile = escapeshellcmd($this->targetfile);
+ $targetfile = ($this->targetfile);
$escape = OS_WINDOWS?'"':'\'';
- $cmdline = "{$this->python} {$escape}{$this->documentConverter}{$escape} {$escape}{$sourcefile}{$escape} {$escape}{$targetfile}{$escape} {$this->ooHost} {$this->ooPort}";
+ $cmdline = "{$escape}{$this->python}{$escape} {$escape}{$this->documentConverter}{$escape} {$escape}{$sourcefile}{$escape} {$escape}{$targetfile}{$escape} {$this->ooHost} {$this->ooPort}";
return $cmdline;
}
diff --git a/search2/indexing/indexerCore.inc.php b/search2/indexing/indexerCore.inc.php
index 183995e..ce037fe 100644
--- a/search2/indexing/indexerCore.inc.php
+++ b/search2/indexing/indexerCore.inc.php
@@ -67,6 +67,10 @@ class QueryResultItem
protected $deleted;
protected $status;
protected $folderId;
+ protected $storagePath;
+ protected $documentType;
+ protected $mimeIconPath;
+ protected $mimeDisplay;
public function __construct($document_id, $rank=null, $title=null, $text=null)
{
@@ -100,12 +104,14 @@ class QueryResultItem
d.folder_id, f.full_path, f.name, dcv.size as filesize, dcv.major_version,
dcv.minor_version, dcv.filename, cou.name as checkoutuser, w.human_name as workflow, ws.human_name as workflowstate,
mt.mimetypes as mimetype, md.mime_doc as mimedoc, d.checkedout, mbu.name as modifiedbyuser, d.modified,
- cbu.name as createdbyuser, ou.name as owneruser, d.immutable, d.status_id, d.created
+ cbu.name as createdbyuser, ou.name as owneruser, d.immutable, d.status_id, d.created,dcv.storage_path, dtl.name as document_type,
+ mt.icon_path as mime_icon_path, mt.friendly_name as mime_display
FROM
documents d
INNER JOIN document_metadata_version dmv ON d.metadata_version_id = dmv.id
INNER JOIN document_content_version dcv ON dmv.content_version_id = dcv.id
INNER JOIN mime_types mt ON dcv.mime_id=mt.id
+ LEFT JOIN document_types_lookup dtl ON dtl.id=dmv.document_type_id
LEFT JOIN folders f ON f.id=d.folder_id
LEFT JOIN users cou ON d.checked_out_user_id=cou.id
LEFT JOIN workflows w ON dmv.workflow_id=w.id
@@ -134,6 +140,31 @@ class QueryResultItem
throw new Exception(_kt($msg));
}
+ // document_id, relevance, text, title
+
+ $this->documentType = $result['document_type'];
+ $this->filename=$result['filename'];
+ $this->filesize = KTUtil::filesizeToString($result['filesize']);
+ $this->folderId = $result['folder_id'];
+
+ $this->createdBy = $result['createdbyuser'];
+ $this->dateCreated = $result['created'];
+
+ $this->modifiedBy = $result['modifiedbyuser'];
+ $this->dateModified = $result['modified'];
+
+ $this->checkedOutUser = $result['checkoutuser'];
+ $this->dateCheckedout = $result['checkedout'];
+
+ $this->owner = $result['owneruser'];
+
+ $this->version = $result['major_version'] . '.' . $result['minor_version'];
+
+ $this->immutable = ($result['immutable'] + 0)?_kt('Immutable'):'';
+
+ $this->workflow = $result['workflow'];
+ $this->workflowState = $result['workflowstate'];
+
if (is_null($result['name']))
{
$this->fullpath = '(orphaned)';
@@ -144,28 +175,12 @@ class QueryResultItem
if (substr($this->fullpath,0,1) == '/') $this->fullpath = substr($this->fullpath,1);
}
- $this->filesize = KTUtil::filesizeToString($result['filesize']);
-
- $this->version = $result['major_version'] . '.' . $result['minor_version'];
- $this->filename=$result['filename'];
- $this->checkedOutUser = $result['checkoutuser'];
- $this->workflow = $result['workflow'];
- $this->workflowState = $result['workflowstate'];
-
-
$this->mimeType = $result['mimetype'];
- $this->dateCheckedout = $result['checkedout'];
-
- $this->modifiedBy = $result['modifiedbyuser'];
- $this->dateModified = $result['modified'];
- $this->createdBy = $result['createdbyuser'];
- $this->dateCreated = $result['created'];
+ $this->mimeIconPath = $result['mime_icon_path'];
+ $this->mimeDisplay = $result['mime_display'];
- $this->owner = $result['owneruser'];
- $this->immutable = ($result['immutable'] + 0)?_kt('Immutable'):'';
+ $this->storagePath = $result['storage_path'];
$this->status = Document::getStatusString($result['status_id']);
- $this->folderId = $result['folder_id'];
-
}
protected function __get($property)
@@ -193,12 +208,15 @@ class QueryResultItem
case 'IsAvailable':
return $this->Document->isLive();
case 'CheckedOutUser':
+ case 'CheckedOutBy':
return (string) $this->checkedOutUser;
case 'WorkflowOnly':
+ case 'Workflow':
return (string)$this->workflow;
case 'WorkflowStateOnly':
+ case 'WorkflowState':
return (string)$this->workflowState;
- case 'Workflow':
+ case 'WorkflowAndState':
if (is_null($this->workflow))
{
return '';
@@ -206,6 +224,10 @@ class QueryResultItem
return "$this->workflow - $this->workflowState";
case 'MimeType':
return (string) $this->mimeType;
+ case 'MimeIconPath':
+ return (string) $this->mimeIconPath;
+ case 'MimeDisplay':
+ return (string) $this->mimeDisplay;
case 'DateCheckedOut':
return (string) $this->dateCheckedout;
case 'ModifiedBy':
@@ -217,11 +239,19 @@ class QueryResultItem
case 'DateCreated':
return (string) $this->dateCreated;
case 'Owner':
+ case 'OwnedBy':
return (string) $this->owner;
+ case 'IsImmutable':
case 'Immutable':
return (bool) $this->immutable;
case 'Status':
return $this->status;
+ case 'StoragePath':
+ return $this->storagePath;
+ case 'DocumentType':
+ return $this->documentType;
+ case 'Permissions':
+ return 'not available';
case 'CanBeReadByUser':
if (!$this->live)
return false;
@@ -231,7 +261,7 @@ class QueryResultItem
return true;
return false;
default:
- throw new Exception("Unknown property '$property' to get on MatchResult");
+ throw new Exception("Unknown property '$property' to get on QueryResultItem");
}
return ''; // Should not be reached
}
@@ -766,6 +796,7 @@ abstract class Indexer
if ($this->debug) $default->log->debug('indexDocuments: stopping - db error');
return;
}
+ KTUtil::setSystemSetting('luceneIndexingDate', time());
// bail if no work to do
if (count($result) == 0)
diff --git a/search2/search/search.inc.php b/search2/search/search.inc.php
index e6b5948..8822599 100644
--- a/search2/search/search.inc.php
+++ b/search2/search/search.inc.php
@@ -554,27 +554,48 @@ function processSearchExpression($query)
{
$item = array(
'document_id' => (int) $hit->DocumentID,
- 'title' => (string) $hit->Title,
+
+ 'custom_document_no' => 'n/a',
+ 'oem_document_no' => 'n/a',
+
'relevance' => (float) $hit->Rank,
'text' => (string) $noText?'':$hit->Text,
- 'filesize' => (int) $hit->Filesize,
+
+ 'title' => (string) $hit->Title,
+ 'document_type'=> $hit->DocumentType,
'fullpath' => (string) $hit->FullPath,
- 'version' => (string) $hit->Version,
'filename' => (string) $hit->Filename,
- 'checked_out_by' => (string) $hit->CheckedOutUser,
+ 'filesize' => (int) $hit->Filesize,
+ 'folder_id' => (int) $hit->FolderId,
+
+ 'created_by' => (string) $hit->CreatedBy,
+ 'created_date' => (string) $hit->DateCreated,
+
+ 'modified_by' => (string) $hit->ModifiedBy,
+ 'modified_date' => (string) $hit->DateModified,
+
+ 'checked_out_by' => (string) $hit->CheckedOutUser,
'checked_out_date' => (string) $hit->DateCheckedOut,
- 'is_available' => (bool) $hit->IsAvailable,
+
+ 'owned_by' => (string) $hit->Owner,
+
+ 'version' => (float) $hit->Version,
+ 'is_immutable'=> (bool) $hit->Immutable,
+ 'permissions'=> $hit->Permissions,
+
'workflow' => (string) $hit->WorkflowOnly,
'workflow_state' => (string) $hit->WorkflowStateOnly,
- 'folder_id' => (int) $hit->FolderId,
+
'mime_type' => (string) $hit->MimeType,
- 'modified_by' => (string) $hit->ModifiedBy,
- 'modified_date' => (string) $hit->DateModified,
- 'created_by' => (string) $hit->CreatedBy,
- 'created_date' => (string) $hit->DateCreated,
- 'owner' => (string) $hit->Owner,
- 'is_immutable'=> (bool) $hit->Immutable,
- 'status' => (string) $hit->Status
+ 'mime_icon_path' => (string) $hit->MimeIconPath,
+ 'mime_display' => (string) $hit->MimeDisplay,
+
+ 'storage_path' => (string) $hit->StoragePath,
+
+ 'status' => (string) $hit->Status,
+
+ 'is_available' => (bool) $hit->IsAvailable,
+
);
$results[] = $item;
diff --git a/sql/mysql/install/data.sql b/sql/mysql/install/data.sql
index c7a23cf..6c52c14 100644
--- a/sql/mysql/install/data.sql
+++ b/sql/mysql/install/data.sql
@@ -582,7 +582,7 @@ UNLOCK TABLES;
LOCK TABLES `mime_types` WRITE;
/*!40000 ALTER TABLE `mime_types` DISABLE KEYS */;
-INSERT INTO `mime_types` VALUES (1,'ai','application/postscript','pdf','Postscript Document',NULL,NULL),(2,'aif','audio/x-aiff',NULL,'',NULL,NULL),(3,'aifc','audio/x-aiff',NULL,'',NULL,NULL),(4,'aiff','audio/x-aiff',NULL,'',NULL,NULL),(5,'asc','text/plain','text','Plain Text',NULL,NULL),(6,'au','audio/basic',NULL,'',NULL,NULL),(7,'avi','video/x-msvideo',NULL,'Video File',NULL,NULL),(8,'bcpio','application/x-bcpio',NULL,'',NULL,NULL),(9,'bin','application/octet-stream',NULL,'Binary File',NULL,NULL),(10,'bmp','image/bmp','image','BMP Image',NULL,NULL),(11,'cdf','application/x-netcdf',NULL,'',NULL,NULL),(12,'class','application/octet-stream',NULL,'',NULL,NULL),(13,'cpio','application/x-cpio',NULL,'',NULL,NULL),(14,'cpt','application/mac-compactpro',NULL,'',NULL,NULL),(15,'csh','application/x-csh',NULL,'',NULL,NULL),(16,'css','text/css',NULL,'',NULL,NULL),(17,'dcr','application/x-director',NULL,'',NULL,NULL),(18,'dir','application/x-director',NULL,'',NULL,NULL),(19,'dms','application/octet-stream',NULL,'',NULL,NULL),(20,'doc','application/msword','word','Word Document',NULL,NULL),(21,'dvi','application/x-dvi',NULL,'',NULL,NULL),(22,'dxr','application/x-director',NULL,'',NULL,NULL),(23,'eps','application/postscript','pdf','Encapsulated Postscript',NULL,NULL),(24,'etx','text/x-setext',NULL,'',NULL,NULL),(25,'exe','application/octet-stream',NULL,'',NULL,NULL),(26,'ez','application/andrew-inset',NULL,'',NULL,NULL),(27,'gif','image/gif','image','GIF Image',NULL,NULL),(28,'gtar','application/x-gtar','compressed','',NULL,NULL),(29,'hdf','application/x-hdf',NULL,'',NULL,NULL),(30,'hqx','application/mac-binhex40',NULL,'',NULL,NULL),(31,'htm','text/html','html','HTML Webpage',NULL,NULL),(32,'html','text/html','html','HTML Webpage',NULL,NULL),(33,'ice','x-conference/x-cooltalk',NULL,'',NULL,NULL),(34,'ief','image/ief','image','',NULL,NULL),(35,'iges','model/iges',NULL,'',NULL,NULL),(36,'igs','model/iges',NULL,'',NULL,NULL),(37,'jpe','image/jpeg','image','JPEG Image',NULL,NULL),(38,'jpeg','image/jpeg','image','JPEG Image',NULL,NULL),(39,'jpg','image/jpeg','image','JPEG Image',NULL,NULL),(40,'js','application/x-javascript','html','',NULL,NULL),(41,'kar','audio/midi',NULL,'',NULL,NULL),(42,'latex','application/x-latex',NULL,'',NULL,NULL),(43,'lha','application/octet-stream',NULL,'',NULL,NULL),(44,'lzh','application/octet-stream',NULL,'',NULL,NULL),(45,'man','application/x-troff-man',NULL,'',NULL,NULL),(46,'mdb','application/access','database','Access Database',NULL,NULL),(47,'mdf','application/access','database','Access Database',NULL,NULL),(48,'me','application/x-troff-me',NULL,'',NULL,NULL),(49,'mesh','model/mesh',NULL,'',NULL,NULL),(50,'mid','audio/midi',NULL,'',NULL,NULL),(51,'midi','audio/midi',NULL,'',NULL,NULL),(52,'mif','application/vnd.mif',NULL,'',NULL,NULL),(53,'mov','video/quicktime',NULL,'Video File',NULL,NULL),(54,'movie','video/x-sgi-movie',NULL,'Video File',NULL,NULL),(55,'mp2','audio/mpeg',NULL,'',NULL,NULL),(56,'mp3','audio/mpeg',NULL,'',NULL,NULL),(57,'mpe','video/mpeg',NULL,'Video File',NULL,NULL),(58,'mpeg','video/mpeg',NULL,'Video File',NULL,NULL),(59,'mpg','video/mpeg',NULL,'Video File',NULL,NULL),(60,'mpga','audio/mpeg',NULL,'',NULL,NULL),(61,'mpp','application/vnd.ms-project','office','',NULL,NULL),(62,'ms','application/x-troff-ms',NULL,'',NULL,NULL),(63,'msh','model/mesh',NULL,'',NULL,NULL),(64,'nc','application/x-netcdf',NULL,'',NULL,NULL),(65,'oda','application/oda',NULL,'',NULL,NULL),(66,'pbm','image/x-portable-bitmap','image','',NULL,NULL),(67,'pdb','chemical/x-pdb',NULL,'',NULL,NULL),(68,'pdf','application/pdf','pdf','Acrobat PDF',NULL,NULL),(69,'pgm','image/x-portable-graymap','image','',NULL,NULL),(70,'pgn','application/x-chess-pgn',NULL,'',NULL,NULL),(71,'png','image/png','image','PNG Image',NULL,NULL),(72,'pnm','image/x-portable-anymap','image','',NULL,NULL),(73,'ppm','image/x-portable-pixmap','image','',NULL,NULL),(74,'ppt','application/vnd.ms-powerpoint','office','Powerpoint Presentation',NULL,NULL),(75,'ps','application/postscript','pdf','Postscript Document',NULL,NULL),(76,'qt','video/quicktime',NULL,'Video File',NULL,NULL),(77,'ra','audio/x-realaudio',NULL,'',NULL,NULL),(78,'ram','audio/x-pn-realaudio',NULL,'',NULL,NULL),(79,'ras','image/x-cmu-raster','image','',NULL,NULL),(80,'rgb','image/x-rgb','image','',NULL,NULL),(81,'rm','audio/x-pn-realaudio',NULL,'',NULL,NULL),(82,'roff','application/x-troff',NULL,'',NULL,NULL),(83,'rpm','audio/x-pn-realaudio-plugin',NULL,'',NULL,NULL),(84,'rtf','text/rtf',NULL,'',NULL,NULL),(85,'rtx','text/richtext',NULL,'',NULL,NULL),(86,'sgm','text/sgml',NULL,'',NULL,NULL),(87,'sgml','text/sgml',NULL,'',NULL,NULL),(88,'sh','application/x-sh',NULL,'',NULL,NULL),(89,'shar','application/x-shar',NULL,'',NULL,NULL),(90,'silo','model/mesh',NULL,'',NULL,NULL),(91,'sit','application/x-stuffit',NULL,'',NULL,NULL),(92,'skd','application/x-koan',NULL,'',NULL,NULL),(93,'skm','application/x-koan',NULL,'',NULL,NULL),(94,'skp','application/x-koan',NULL,'',NULL,NULL),(95,'skt','application/x-koan',NULL,'',NULL,NULL),(96,'smi','application/smil',NULL,'',NULL,NULL),(97,'smil','application/smil',NULL,'',NULL,NULL),(98,'snd','audio/basic',NULL,'',NULL,NULL),(99,'spl','application/x-futuresplash',NULL,'',NULL,NULL),(100,'src','application/x-wais-source',NULL,'',NULL,NULL),(101,'sv4cpio','application/x-sv4cpio',NULL,'',NULL,NULL),(102,'sv4crc','application/x-sv4crc',NULL,'',NULL,NULL),(103,'swf','application/x-shockwave-flash',NULL,'',NULL,NULL),(104,'t','application/x-troff',NULL,'',NULL,NULL),(105,'tar','application/x-tar','compressed','Tar or Compressed Tar File',NULL,NULL),(106,'tcl','application/x-tcl',NULL,'',NULL,NULL),(107,'tex','application/x-tex',NULL,'',NULL,NULL),(108,'texi','application/x-texinfo',NULL,'',NULL,NULL),(109,'texinfo','application/x-texinfo',NULL,'',NULL,NULL),(110,'tif','image/tiff','image','TIFF Image',NULL,NULL),(111,'tiff','image/tiff','image','TIFF Image',NULL,NULL),(112,'tr','application/x-troff',NULL,'',NULL,NULL),(113,'tsv','text/tab-separated-values',NULL,'',NULL,NULL),(114,'txt','text/plain','text','Plain Text',NULL,NULL),(115,'ustar','application/x-ustar',NULL,'',NULL,NULL),(116,'vcd','application/x-cdlink',NULL,'',NULL,NULL),(117,'vrml','model/vrml',NULL,'',NULL,NULL),(118,'vsd','application/vnd.visio','office','',NULL,NULL),(119,'wav','audio/x-wav',NULL,'',NULL,NULL),(120,'wrl','model/vrml',NULL,'',NULL,NULL),(121,'xbm','image/x-xbitmap','image','',NULL,NULL),(122,'xls','application/vnd.ms-excel','excel','Excel Spreadsheet',NULL,NULL),(123,'xml','text/xml',NULL,'',NULL,NULL),(124,'xpm','image/x-xpixmap','image','',NULL,NULL),(125,'xwd','image/x-xwindowdump','image','',NULL,NULL),(126,'xyz','chemical/x-pdb',NULL,'',NULL,NULL),(127,'zip','application/zip','compressed','ZIP Compressed File',NULL,NULL),(128,'gz','application/x-gzip','compressed','GZIP Compressed File',NULL,NULL),(129,'tgz','application/x-gzip','compressed','Tar or Compressed Tar File',NULL,NULL),(130,'sxw','application/vnd.sun.xml.writer','openoffice','OpenOffice.org Writer Document',NULL,NULL),(131,'stw','application/vnd.sun.xml.writer.template','openoffice','OpenOffice.org File',NULL,NULL),(132,'sxc','application/vnd.sun.xml.calc','openoffice','OpenOffice.org Spreadsheet',NULL,NULL),(133,'stc','application/vnd.sun.xml.calc.template','openoffice','OpenOffice.org File',NULL,NULL),(134,'sxd','application/vnd.sun.xml.draw','openoffice','OpenOffice.org File',NULL,NULL),(135,'std','application/vnd.sun.xml.draw.template','openoffice','OpenOffice.org File',NULL,NULL),(136,'sxi','application/vnd.sun.xml.impress','openoffice','OpenOffice.org Presentation',NULL,NULL),(137,'sti','application/vnd.sun.xml.impress.template','openoffice','OpenOffice.org File',NULL,NULL),(138,'sxg','application/vnd.sun.xml.writer.global','openoffice','OpenOffice.org File',NULL,NULL),(139,'sxm','application/vnd.sun.xml.math','openoffice','OpenOffice.org File',NULL,NULL),(140,'xlt','application/vnd.ms-excel','excel','Excel Template',NULL,NULL),(141,'dot','application/msword','word','Word Template',NULL,NULL),(142,'bz2','application/x-bzip2','compressed','BZIP2 Compressed File',NULL,NULL),(143,'diff','text/plain','text','Source Diff File',NULL,NULL),(144,'patch','text/plain','text','Patch File',NULL,NULL),(145,'odt','application/vnd.oasis.opendocument.text','opendocument','OpenDocument Text',NULL,NULL),(146,'ott','application/vnd.oasis.opendocument.text-template','opendocument','OpenDocument Text Template',NULL,NULL),(147,'oth','application/vnd.oasis.opendocument.text-web','opendocument','HTML Document Template',NULL,NULL),(148,'odm','application/vnd.oasis.opendocument.text-master','opendocument','OpenDocument Master Document',NULL,NULL),(149,'odg','application/vnd.oasis.opendocument.graphics','opendocument','OpenDocument Drawing',NULL,NULL),(150,'otg','application/vnd.oasis.opendocument.graphics-template','opendocument','OpenDocument Drawing Template',NULL,NULL),(151,'odp','application/vnd.oasis.opendocument.presentation','opendocument','OpenDocument Presentation',NULL,NULL),(152,'otp','application/vnd.oasis.opendocument.presentation-template','opendocument','OpenDocument Presentation Template',NULL,NULL),(153,'ods','application/vnd.oasis.opendocument.spreadsheet','opendocument','OpenDocument Spreadsheet',NULL,NULL),(154,'ots','application/vnd.oasis.opendocument.spreadsheet-template','opendocument','OpenDocument Spreadsheet Template',NULL,NULL),(155,'odc','application/vnd.oasis.opendocument.chart','opendocument','OpenDocument Chart',NULL,NULL),(156,'odf','application/vnd.oasis.opendocument.formula','opendocument','OpenDocument Formula',NULL,NULL),(157,'odb','application/vnd.oasis.opendocument.database','opendocument','OpenDocument Database',NULL,NULL),(158,'odi','application/vnd.oasis.opendocument.image','opendocument','OpenDocument Image',NULL,NULL),(159,'zip','application/x-zip','compressed','ZIP Compressed File',NULL,NULL),(160,'csv','text/csv','spreadsheet','Comma delimited spreadsheet',NULL,NULL),(161,'msi','application/msword','compressed','MSI Installer file',NULL,NULL),(162,'pps','application/vnd.ms-powerpoint','office','Powerpoint Presentation',NULL,NULL);
+INSERT INTO `mime_types` VALUES (1,'ai','application/postscript','pdf','Postscript Document',NULL,NULL),(2,'aif','audio/x-aiff',NULL,'',NULL,NULL),(3,'aifc','audio/x-aiff',NULL,'',NULL,NULL),(4,'aiff','audio/x-aiff',NULL,'',NULL,NULL),(5,'asc','text/plain','text','Plain Text',NULL,NULL),(6,'au','audio/basic',NULL,'',NULL,NULL),(7,'avi','video/x-msvideo',NULL,'Video File',NULL,NULL),(8,'bcpio','application/x-bcpio',NULL,'',NULL,NULL),(9,'bin','application/octet-stream',NULL,'Binary File',NULL,NULL),(10,'bmp','image/bmp','image','BMP Image',NULL,NULL),(11,'cdf','application/x-netcdf',NULL,'',NULL,NULL),(12,'class','application/octet-stream',NULL,'',NULL,NULL),(13,'cpio','application/x-cpio',NULL,'',NULL,NULL),(14,'cpt','application/mac-compactpro',NULL,'',NULL,NULL),(15,'csh','application/x-csh',NULL,'',NULL,NULL),(16,'css','text/css',NULL,'',NULL,NULL),(17,'dcr','application/x-director',NULL,'',NULL,NULL),(18,'dir','application/x-director',NULL,'',NULL,NULL),(19,'dms','application/octet-stream',NULL,'',NULL,NULL),(20,'doc','application/msword','word','Word Document',NULL,NULL),(21,'dvi','application/x-dvi',NULL,'',NULL,NULL),(22,'dxr','application/x-director',NULL,'',NULL,NULL),(23,'eps','application/postscript','pdf','Encapsulated Postscript',NULL,NULL),(24,'etx','text/x-setext',NULL,'',NULL,NULL),(25,'exe','application/octet-stream',NULL,'',NULL,NULL),(26,'ez','application/andrew-inset',NULL,'',NULL,NULL),(27,'gif','image/gif','image','GIF Image',NULL,NULL),(28,'gtar','application/x-gtar','compressed','',NULL,NULL),(29,'hdf','application/x-hdf',NULL,'',NULL,NULL),(30,'hqx','application/mac-binhex40',NULL,'',NULL,NULL),(31,'htm','text/html','html','HTML Webpage',NULL,NULL),(32,'html','text/html','html','HTML Webpage',NULL,NULL),(33,'ice','x-conference/x-cooltalk',NULL,'',NULL,NULL),(34,'ief','image/ief','image','',NULL,NULL),(35,'iges','model/iges',NULL,'',NULL,NULL),(36,'igs','model/iges',NULL,'',NULL,NULL),(37,'jpe','image/jpeg','image','JPEG Image',NULL,NULL),(38,'jpeg','image/jpeg','image','JPEG Image',NULL,NULL),(39,'jpg','image/jpeg','image','JPEG Image',NULL,NULL),(40,'js','application/x-javascript','html','',NULL,NULL),(41,'kar','audio/midi',NULL,'',NULL,NULL),(42,'latex','application/x-latex',NULL,'',NULL,NULL),(43,'lha','application/octet-stream',NULL,'',NULL,NULL),(44,'lzh','application/octet-stream',NULL,'',NULL,NULL),(45,'man','application/x-troff-man',NULL,'',NULL,NULL),(46,'mdb','application/access','database','Access Database',NULL,NULL),(47,'mdf','application/access','database','Access Database',NULL,NULL),(48,'me','application/x-troff-me',NULL,'',NULL,NULL),(49,'mesh','model/mesh',NULL,'',NULL,NULL),(50,'mid','audio/midi',NULL,'',NULL,NULL),(51,'midi','audio/midi',NULL,'',NULL,NULL),(52,'mif','application/vnd.mif',NULL,'',NULL,NULL),(53,'mov','video/quicktime',NULL,'Video File',NULL,NULL),(54,'movie','video/x-sgi-movie',NULL,'Video File',NULL,NULL),(55,'mp2','audio/mpeg',NULL,'',NULL,NULL),(56,'mp3','audio/mpeg',NULL,'',NULL,NULL),(57,'mpe','video/mpeg',NULL,'Video File',NULL,NULL),(58,'mpeg','video/mpeg',NULL,'Video File',NULL,NULL),(59,'mpg','video/mpeg',NULL,'Video File',NULL,NULL),(60,'mpga','audio/mpeg',NULL,'',NULL,NULL),(61,'mpp','application/vnd.ms-project','office','',NULL,NULL),(62,'ms','application/x-troff-ms',NULL,'',NULL,NULL),(63,'msh','model/mesh',NULL,'',NULL,NULL),(64,'nc','application/x-netcdf',NULL,'',NULL,NULL),(65,'oda','application/oda',NULL,'',NULL,NULL),(66,'pbm','image/x-portable-bitmap','image','',NULL,NULL),(67,'pdb','chemical/x-pdb',NULL,'',NULL,NULL),(68,'pdf','application/pdf','pdf','Acrobat PDF',NULL,NULL),(69,'pgm','image/x-portable-graymap','image','',NULL,NULL),(70,'pgn','application/x-chess-pgn',NULL,'',NULL,NULL),(71,'png','image/png','image','PNG Image',NULL,NULL),(72,'pnm','image/x-portable-anymap','image','',NULL,NULL),(73,'ppm','image/x-portable-pixmap','image','',NULL,NULL),(74,'ppt','application/vnd.ms-powerpoint','office','Powerpoint Presentation',NULL,NULL),(75,'ps','application/postscript','pdf','Postscript Document',NULL,NULL),(76,'qt','video/quicktime',NULL,'Video File',NULL,NULL),(77,'ra','audio/x-realaudio',NULL,'',NULL,NULL),(78,'ram','audio/x-pn-realaudio',NULL,'',NULL,NULL),(79,'ras','image/x-cmu-raster','image','',NULL,NULL),(80,'rgb','image/x-rgb','image','',NULL,NULL),(81,'rm','audio/x-pn-realaudio',NULL,'',NULL,NULL),(82,'roff','application/x-troff',NULL,'',NULL,NULL),(83,'rpm','audio/x-pn-realaudio-plugin',NULL,'',NULL,NULL),(84,'rtf','text/rtf',NULL,'',NULL,NULL),(85,'rtx','text/richtext',NULL,'',NULL,NULL),(86,'sgm','text/sgml',NULL,'',NULL,NULL),(87,'sgml','text/sgml',NULL,'',NULL,NULL),(88,'sh','application/x-sh',NULL,'',NULL,NULL),(89,'shar','application/x-shar',NULL,'',NULL,NULL),(90,'silo','model/mesh',NULL,'',NULL,NULL),(91,'sit','application/x-stuffit',NULL,'',NULL,NULL),(92,'skd','application/x-koan',NULL,'',NULL,NULL),(93,'skm','application/x-koan',NULL,'',NULL,NULL),(94,'skp','application/x-koan',NULL,'',NULL,NULL),(95,'skt','application/x-koan',NULL,'',NULL,NULL),(96,'smi','application/smil',NULL,'',NULL,NULL),(97,'smil','application/smil',NULL,'',NULL,NULL),(98,'snd','audio/basic',NULL,'',NULL,NULL),(99,'spl','application/x-futuresplash',NULL,'',NULL,NULL),(100,'src','application/x-wais-source',NULL,'',NULL,NULL),(101,'sv4cpio','application/x-sv4cpio',NULL,'',NULL,NULL),(102,'sv4crc','application/x-sv4crc',NULL,'',NULL,NULL),(103,'swf','application/x-shockwave-flash',NULL,'',NULL,NULL),(104,'t','application/x-troff',NULL,'',NULL,NULL),(105,'tar','application/x-tar','compressed','Tar or Compressed Tar File',NULL,NULL),(106,'tcl','application/x-tcl',NULL,'',NULL,NULL),(107,'tex','application/x-tex',NULL,'',NULL,NULL),(108,'texi','application/x-texinfo',NULL,'',NULL,NULL),(109,'texinfo','application/x-texinfo',NULL,'',NULL,NULL),(110,'tif','image/tiff','image','TIFF Image',NULL,NULL),(111,'tiff','image/tiff','image','TIFF Image',NULL,NULL),(112,'tr','application/x-troff',NULL,'',NULL,NULL),(113,'tsv','text/tab-separated-values',NULL,'',NULL,NULL),(114,'txt','text/plain','text','Plain Text',NULL,NULL),(115,'ustar','application/x-ustar',NULL,'',NULL,NULL),(116,'vcd','application/x-cdlink',NULL,'',NULL,NULL),(117,'vrml','model/vrml',NULL,'',NULL,NULL),(118,'vsd','application/vnd.visio','office','',NULL,NULL),(119,'wav','audio/x-wav',NULL,'',NULL,NULL),(120,'wrl','model/vrml',NULL,'',NULL,NULL),(121,'xbm','image/x-xbitmap','image','',NULL,NULL),(122,'xls','application/vnd.ms-excel','excel','Excel Spreadsheet',NULL,NULL),(123,'xml','text/xml',NULL,'',NULL,NULL),(124,'xpm','image/x-xpixmap','image','',NULL,NULL),(125,'xwd','image/x-xwindowdump','image','',NULL,NULL),(126,'xyz','chemical/x-pdb',NULL,'',NULL,NULL),(127,'zip','application/zip','compressed','ZIP Compressed File',NULL,NULL),(128,'gz','application/x-gzip','compressed','GZIP Compressed File',NULL,NULL),(129,'tgz','application/x-gzip','compressed','Tar or Compressed Tar File',NULL,NULL),(130,'sxw','application/vnd.sun.xml.writer','openoffice','OpenOffice.org Writer Document',NULL,NULL),(131,'stw','application/vnd.sun.xml.writer.template','openoffice','OpenOffice.org File',NULL,NULL),(132,'sxc','application/vnd.sun.xml.calc','openoffice','OpenOffice.org Spreadsheet',NULL,NULL),(133,'stc','application/vnd.sun.xml.calc.template','openoffice','OpenOffice.org File',NULL,NULL),(134,'sxd','application/vnd.sun.xml.draw','openoffice','OpenOffice.org File',NULL,NULL),(135,'std','application/vnd.sun.xml.draw.template','openoffice','OpenOffice.org File',NULL,NULL),(136,'sxi','application/vnd.sun.xml.impress','openoffice','OpenOffice.org Presentation',NULL,NULL),(137,'sti','application/vnd.sun.xml.impress.template','openoffice','OpenOffice.org File',NULL,NULL),(138,'sxg','application/vnd.sun.xml.writer.global','openoffice','OpenOffice.org File',NULL,NULL),(139,'sxm','application/vnd.sun.xml.math','openoffice','OpenOffice.org File',NULL,NULL),(140,'xlt','application/vnd.ms-excel','excel','Excel Template',NULL,NULL),(141,'dot','application/msword','word','Word Template',NULL,NULL),(142,'bz2','application/x-bzip2','compressed','BZIP2 Compressed File',NULL,NULL),(143,'diff','text/plain','text','Source Diff File',NULL,NULL),(144,'patch','text/plain','text','Patch File',NULL,NULL),(145,'odt','application/vnd.oasis.opendocument.text','opendocument','OpenDocument Text',NULL,NULL),(146,'ott','application/vnd.oasis.opendocument.text-template','opendocument','OpenDocument Text Template',NULL,NULL),(147,'oth','application/vnd.oasis.opendocument.text-web','opendocument','HTML Document Template',NULL,NULL),(148,'odm','application/vnd.oasis.opendocument.text-master','opendocument','OpenDocument Master Document',NULL,NULL),(149,'odg','application/vnd.oasis.opendocument.graphics','opendocument','OpenDocument Drawing',NULL,NULL),(150,'otg','application/vnd.oasis.opendocument.graphics-template','opendocument','OpenDocument Drawing Template',NULL,NULL),(151,'odp','application/vnd.oasis.opendocument.presentation','opendocument','OpenDocument Presentation',NULL,NULL),(152,'otp','application/vnd.oasis.opendocument.presentation-template','opendocument','OpenDocument Presentation Template',NULL,NULL),(153,'ods','application/vnd.oasis.opendocument.spreadsheet','opendocument','OpenDocument Spreadsheet',NULL,NULL),(154,'ots','application/vnd.oasis.opendocument.spreadsheet-template','opendocument','OpenDocument Spreadsheet Template',NULL,NULL),(155,'odc','application/vnd.oasis.opendocument.chart','opendocument','OpenDocument Chart',NULL,NULL),(156,'odf','application/vnd.oasis.opendocument.formula','opendocument','OpenDocument Formula',NULL,NULL),(157,'odb','application/vnd.oasis.opendocument.database','opendocument','OpenDocument Database',NULL,NULL),(158,'odi','application/vnd.oasis.opendocument.image','opendocument','OpenDocument Image',NULL,NULL),(159,'zip','application/x-zip','compressed','ZIP Compressed File',NULL,NULL),(160,'csv','text/csv','excel','Comma delimited spreadsheet',NULL,NULL),(161,'msi','application/msword','compressed','MSI Installer file',NULL,NULL),(162,'pps','application/vnd.ms-powerpoint','office','Powerpoint Presentation',NULL,NULL);
/*!40000 ALTER TABLE `mime_types` ENABLE KEYS */;
UNLOCK TABLES;
@@ -798,7 +798,8 @@ INSERT INTO `scheduler_tasks` VALUES
(1,'Indexing','search2/indexing/bin/cronIndexer.php','',0,'1min','2007-10-01',NULL,0,'system'),
(2,'Index Migration','search2/indexing/bin/cronMigration.php','',0,'5mins','2007-10-01',NULL,0,'system'),
(3,'Index Optimisation','search2/indexing/bin/optimise.php','',0,'weekly','2007-10-01',NULL,0,'system'),
-(4,'Periodic Document Expunge','bin/expungeall.php','',0,'weekly','2007-10-01',NULL,0,'disabled');
+(4,'Periodic Document Expunge','bin/expungeall.php','',0,'weekly','2007-10-01',NULL,0,'disabled'),
+(5,'Database Maintenance','bin/dbmaint.php','optimize',0,'monthly','2007-10-01',NULL,0,'disabled');
/*!40000 ALTER TABLE `scheduler_tasks` ENABLE KEYS */;
UNLOCK TABLES;
@@ -953,7 +954,10 @@ INSERT INTO `upgrades` VALUES (1,'sql*2.0.6*0*2.0.6/create_upgrade_table.sql','D
(156,'sql*3.5.1*0*3.5.1/png_mime_type.sql','Register PNG mimetype.','2007-11-21 00:00:00',1,'upgrade*3.5.1*99*upgrade3.5.1'),
(157,'upgrade*3.5.1*99*upgrade3.5.1','Upgrade from version 3.5.0 to 3.5.1','2007-11-21 00:00:00',1,'upgrade*3.5.1*99*upgrade3.5.1'),
(158,'sql*3.5.2*0*3.5.2/document_transactions.sql','Updates document_transactions table. Changes chars to varchars.','2007-11-21 00:00:00',1,'upgrade*3.5.2*99*upgrade3.5.2'),
-(159,'upgrade*3.5.2*99*upgrade3.5.2','Upgrade from version 3.5.1 to 3.5.2','2007-11-21 00:00:00',1,'upgrade*3.5.2*99*upgrade3.5.2');
+(159,'sql*3.5.2*0*3.5.2/metadata_length.sql','Updates metadata length. Changes chars to varchars.','2007-11-21 00:00:00',1,'upgrade*3.5.2*99*upgrade3.5.2'),
+(160,'sql*3.5.2*0*3.5.2/scheduler_tasks.sql','Initialise some scheduler tasks.','2007-11-21 00:00:00',1,'upgrade*3.5.2*99*upgrade3.5.2'),
+(161,'sql*3.5.2*0*3.5.2/csv_mime.sql','Update mime types for CSV files.','2007-11-21 00:00:00',1,'upgrade*3.5.2*99*upgrade3.5.2'),
+(162,'upgrade*3.5.2*99*upgrade3.5.2','Upgrade from version 3.5.1 to 3.5.2','2007-11-21 00:00:00',1,'upgrade*3.5.2*99*upgrade3.5.2');
/*!40000 ALTER TABLE `upgrades` ENABLE KEYS */;
UNLOCK TABLES;
@@ -1810,7 +1814,7 @@ UNLOCK TABLES;
LOCK TABLES `zseq_upgrades` WRITE;
/*!40000 ALTER TABLE `zseq_upgrades` DISABLE KEYS */;
-INSERT INTO `zseq_upgrades` VALUES (159);
+INSERT INTO `zseq_upgrades` VALUES (162);
/*!40000 ALTER TABLE `zseq_upgrades` ENABLE KEYS */;
UNLOCK TABLES;
diff --git a/sql/mysql/install/structure.sql b/sql/mysql/install/structure.sql
index d8af55d..3157e9f 100644
--- a/sql/mysql/install/structure.sql
+++ b/sql/mysql/install/structure.sql
@@ -289,7 +289,7 @@ CREATE TABLE `document_fields` (
CREATE TABLE `document_fields_link` (
`id` int(11) NOT NULL default '0',
`document_field_id` int(11) NOT NULL default '0',
- `value` char(255) NOT NULL default '',
+ `value` mediumtext NOT NULL default '',
`metadata_version_id` int(11) default NULL,
PRIMARY KEY (`id`),
KEY `document_field_id` (`document_field_id`),
diff --git a/sql/mysql/upgrade/3.5.2/csv_mime.sql b/sql/mysql/upgrade/3.5.2/csv_mime.sql
new file mode 100644
index 0000000..7fe26d7
--- /dev/null
+++ b/sql/mysql/upgrade/3.5.2/csv_mime.sql
@@ -0,0 +1 @@
+update mime_types set icon_path='excel' where filetypes = 'csv';
\ No newline at end of file
diff --git a/sql/mysql/upgrade/3.5.2/document_transactions.sql b/sql/mysql/upgrade/3.5.2/document_transactions.sql
index 63ca630..6327c9a 100644
--- a/sql/mysql/upgrade/3.5.2/document_transactions.sql
+++ b/sql/mysql/upgrade/3.5.2/document_transactions.sql
@@ -1,5 +1,5 @@
-alter table document_transactions change version version varchar(50);
-alter table document_transactions change ip ip varchar(15);
-alter table document_transactions change filename filename varchar(255);
-alter table document_transactions change comment comment varchar(1024);
+alter table document_transactions change version version varchar(50);
+alter table document_transactions change ip ip varchar(15);
+alter table document_transactions change filename filename mediumtext;
+alter table document_transactions change comment comment mediumtext;
alter table document_transactions change transaction_namespace transaction_namespace varchar(255);
\ No newline at end of file
diff --git a/sql/mysql/upgrade/3.5.2/metadata_length.sql b/sql/mysql/upgrade/3.5.2/metadata_length.sql
new file mode 100644
index 0000000..668fb34
--- /dev/null
+++ b/sql/mysql/upgrade/3.5.2/metadata_length.sql
@@ -0,0 +1 @@
+alter table document_fields_link change value value mediumtext not null;
\ No newline at end of file
diff --git a/sql/mysql/upgrade/3.5.2/scheduler_tasks.sql b/sql/mysql/upgrade/3.5.2/scheduler_tasks.sql
index 87af221..acc64a1 100644
--- a/sql/mysql/upgrade/3.5.2/scheduler_tasks.sql
+++ b/sql/mysql/upgrade/3.5.2/scheduler_tasks.sql
@@ -2,4 +2,10 @@ ALTER TABLE `scheduler_tasks` ADD `status` ENUM( 'enabled', 'disabled', 'sy
UPDATE `scheduler_tasks` SET `status` = 'system' WHERE `task` = 'Indexing' OR `task` = 'Index Migration' OR `task` = 'Index Optimisation';
-INSERT INTO `scheduler_tasks` VALUES (4,'Periodic Document Expunge','bin/expungeall.php','',0,'weekly','2007-10-01',NULL,0,'disabled');
\ No newline at end of file
+select @id:=ifnull(max(id),0)+1 from scheduler_tasks;
+INSERT INTO `scheduler_tasks` VALUES (@id,'Periodic Document Expunge','bin/expungeall.php','',0,'weekly','2007-10-01',NULL,0,'disabled');
+
+select @id:=max(id)+1 from scheduler_tasks;
+INSERT INTO `scheduler_tasks` VALUES (@id,'Database Maintenance','bin/dbmaint.php','optimize',0,'monthly','2007-10-01',NULL,0,'disabled');
+
+UPDATE zseq_scheduler_tasks set id=@id;
\ No newline at end of file
diff --git a/templates/ktcore/login.smarty b/templates/ktcore/login.smarty
index b996414..3d80c42 100644
--- a/templates/ktcore/login.smarty
+++ b/templates/ktcore/login.smarty
@@ -11,7 +11,7 @@
-
+
diff --git a/templates/ktcore/search2/lucene_statistics.smarty b/templates/ktcore/search2/lucene_statistics.smarty
index 7bb15e0..bd75056 100644
--- a/templates/ktcore/search2/lucene_statistics.smarty
+++ b/templates/ktcore/search2/lucene_statistics.smarty
@@ -3,44 +3,26 @@
{literal}
@@ -49,44 +31,35 @@ function tog2(){
-
{i18n}Last Optimization Date:{/i18n}
{$stats.optimisationDate}
-
-
{i18n}Period Since Last Optimization:{/i18n}
{$stats.optimisationPeriod}
-
{i18n}Last Indexing Date:{/i18n}
{$stats.indexingDate}
-
{i18n}Period Since Last Indexing:{/i18n}
{$stats.indexingPeriod}
-
{i18n}Total # Documents in Repository:{/i18n}
{$stats.docsInRepository}
-
{i18n}Documents Indexed:{/i18n}
{$stats.docsInIndex}
-
{i18n}Documents in Indexing Queue:{/i18n}
{$stats.docsInQueue}
-
-
-
-Index Coverage:
-
-
-
-Index Coverage:
-
+
{i18n}Last Optimization Date:{/i18n}
{$stats.optimisationDate}
+
{i18n}Period Since Last Optimization:{/i18n}
{$stats.optimisationPeriod}
+
{i18n}Last Indexing Date:{/i18n}
{$stats.indexingDate}
+
{i18n}Period Since Last Indexing:{/i18n}
{$stats.indexingPeriod}
+
{i18n}Total # Documents in Repository:{/i18n}
{$stats.docsInRepository}
+
{i18n}Documents Indexed:{/i18n}
{$stats.docsInIndex}
+
{i18n}Documents in Indexing Queue:{/i18n}
{$stats.docsInQueue}
+
+
+{i18n}Index Coverage:{/i18n}
-
-{i18n}Indexing coverage percentage may vary from total - not all documents contain text.{/i18n}
+
+
+{i18n}Indexing coverage percentage may vary from total - not all documents contain text.{/i18n}
-
{$stats.indexingCoverage}
+
+
{$stats.indexingCoverage}
-
-
-
-Queue Coverage:
-
-
-
-Queue Coverage:
-
+
+
+{i18n}Queue Coverage :{/i18n}
-
-{i18n}Queue coverage indicates percentage of documents currently queued for indexing in relation to total repository size{/i18n}
+
+
+{i18n}Queue coverage indicates percentage of documents currently queued for indexing in relation to total repository size.{/i18n}