📄 webservice.php.tmp
字号:
<?php//debugger_start_debug();/** * * $Id$ * * This implements the KnowledgeTree Web Service in SOAP. * * KnowledgeTree Community Edition * Document Management Made Simple * Copyright (C) 2008 KnowledgeTree Inc. * Portions copyright 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 <http://www.gnu.org/licenses/>. * * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, * California 94120-7775, or email info@knowledgetree.com. * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU General Public License version 3. * * In accordance with Section 7(b) of the GNU General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * KnowledgeTree" logo and retain the original copyright notice. If the display of the * 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): ______________________________________ * */require_once('../config/dmsDefaults.php');require_once('../ktapi/ktapi.inc.php');require_once('SOAP/Server.php');require_once('SOAP/Disco.php');require_once('KTDownloadManager.inc.php');require_once('KTUploadManager.inc.php');require_once(KT_LIB_DIR . '/storage/storagemanager.inc.php');list($major, $minor, $fix) = explode('.', $default->systemVersion);if ($major == 3 && $minor >= 5){ define('HAS_SEARCH_FUNCTIONALITY',1);}unset($major); unset($minor); unset($fix);if (defined('HAS_SEARCH_FUNCTIONALITY')){ require_once(KT_DIR . '/search2/search/search.inc.php');}// TODO: allow downloading of metadata versions// TODO: allow downloading of document versions// TODO: chunking search results// TODO: add basic permissions management - add permissions to folder based on user/groups// TODO: refactor!!! download manager, split this file into a few smaller ones, etc// 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// TODO: subscriptions/notifications// NOTE: some features are not implemented yet. most expected for v3. e.g. oem_document_no, custom_document_no, download($version)., get_metadata($version)// Status Codes as defined in the specification.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_INVALID_WORKFLOW', 27);define('KTWS_ERR_PROBLEM', 98);define('KTWS_ERR_DB_PROBLEM', 99);if (!defined('LATEST_WEBSERVICE_VERSION')){ define('LATEST_WEBSERVICE_VERSION',2);} function bool2str($bool) { if (is_bool($bool)) { return $bool?'true':'false'; } if (is_numeric($bool)) { return ($bool+0)?'true':'false'; } // assume str return (strtolower($bool) == 'true')?'true':'false'; }class KTWebService{ /** * Defines functions, parameters, and return values. * * @var array */ var $__dispatch_map = array(); /** * Defines the structures that are used by web service functions. * * @var array */ var $__typedef = array(); /** * This is the namespace used by the web service. * * @var unknown_type */ var $namespace; var $mustDebug; var $version; var $ktapi; function KTWebService() { // Caching was giving some problems, so disable it. $config = &KTConfig::getSingleton(); $this->version = $config->get('webservice/version', LATEST_WEBSERVICE_VERSION); $this->mustDebug = $config->get('webservice/debug', false); $this->ktapi = null; $this->namespace = 'KnowledgeTree'; $this->__typedef["{urn:$this->namespace}kt_response"] = array( 'status_code' => 'int', 'message' => 'string' ); $this->__typedef["{urn:$this->namespace}kt_folder_detail"] = array( 'status_code'=>'int', 'message'=>'string', 'id' => 'int', 'folder_name' => 'string', 'parent_id' => 'int', 'full_path' => 'string', ); if ($this->version >= 2) { $this->__typedef["{urn:$this->namespace}kt_folder_detail"]['created_by'] = 'string'; } if($this->version >= 3){ $this->__typedef["{urn:$this->namespace}kt_folder_detail"]['linked_folder_id'] = 'int'; } $this->__typedef["{urn:$this->namespace}kt_folder_item"] = array( 'id' => 'int', 'item_type' => 'string', 'title' => 'string', 'creator' => 'string', 'checked_out_by' => 'string', 'modified_by' => 'string', 'filename' => 'string', 'size' => 'string', 'major_version' => 'string', 'minor_version' => 'string', 'storage_path' => 'string', 'mime_type' => 'string', 'mime_icon_path' => 'string', 'mime_display' => 'string', 'workflow'=>'string', 'workflow_state'=>'string', 'items' =>"{urn:$this->namespace}kt_folder_items" ); if ($this->version >= 2) { $this->__typedef["{urn:$this->namespace}kt_folder_item"] = array( 'id' => 'int', 'item_type' => 'string', 'custom_document_no' => 'string', 'oem_document_no' => 'string', 'title' => 'string', 'document_type' => 'string', 'filename' => 'string', 'filesize' => 'string', 'created_by' => 'string', 'created_date' => 'string', 'checked_out_by' => 'string', 'checked_out_date' => 'string', 'modified_by' => 'string', 'modified_date' => 'string', 'owned_by' => 'string', 'version' => 'string', 'is_immutable'=>'string', 'permissions' => 'string', 'workflow'=>'string', 'workflow_state'=>'string', 'mime_type' => 'string', 'mime_icon_path' => 'string', 'mime_display' => 'string', 'storage_path' => 'string', ); if($this->version>=3){ $this->__typedef["{urn:$this->namespace}kt_folder_item"]['linked_folder_id'] = 'int'; } $this->__typedef["{urn:$this->namespace}kt_folder_item"]['items'] = "{urn:$this->namespace}kt_folder_items"; } $this->__typedef["{urn:$this->namespace}kt_folder_items"] = array( array( 'item' => "{urn:$this->namespace}kt_folder_item" ) ); $this->__typedef["{urn:$this->namespace}kt_folder_contents"] = array( 'status_code' => 'int', 'message' => 'string', 'folder_id' => 'int', 'folder_name' => 'string' , 'full_path' => 'string' , 'items' => "{urn:$this->namespace}kt_folder_items", ); $this->__typedef["{urn:$this->namespace}kt_document_detail"] = array( 'status_code'=>'int', 'message'=>'string', 'title' => 'string', 'document_type' => 'string', 'version' => 'string', 'filename' => 'string', 'created_date' => 'string', 'created_by' => 'string', 'updated_date' => 'string', 'updated_by' => 'string', 'document_id' => 'int', 'folder_id' => 'int', 'workflow' => 'string', 'workflow_state' => 'string', 'checkout_by' => 'string', 'full_path' => 'string', ); if ($this->version >= 2) { $this->__typedef["{urn:$this->namespace}kt_document_detail"] = array( 'status_code'=>'int', 'message'=>'string', 'document_id' => 'int', 'custom_document_no' => 'string', 'oem_document_no' => 'string', 'title' => 'string', 'document_type' => 'string', 'full_path' => 'string', 'filename' => 'string', 'filesize' => 'int', 'folder_id' => 'int', 'created_by' => 'string', 'created_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', 'metadata' => "{urn:$this->namespace}kt_metadata_fieldsets", 'links' => "{urn:$this->namespace}kt_linked_documents", 'transitions' => "{urn:$this->namespace}kt_workflow_transitions", 'version_history' => "{urn:$this->namespace}kt_document_version_history", 'transaction_history' => "{urn:$this->namespace}kt_document_transaction_history", ); if($this->version>=3){ $this->__typedef["{urn:$this->namespace}kt_document_detail"]['linked_document_id'] = 'int'; } } if (defined('HAS_SEARCH_FUNCTIONALITY')) { $this->__typedef["{urn:$this->namespace}kt_search_result_item"] = array( 'document_id' => 'int', 'custom_document_no' => 'string',
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -