Commit 457ab620404c1627f9798a1468511fc5ff1b50f3

Authored by kevin_fourie
1 parent e5905bc7

Merged in from DEV trunk...

KTS-2425
"CLONE -When editing permissions of folder, displayed cookie trail using invalid html entity »(SUP-451)"
Fixed. Sanitization issue.

Committed By: Kevin Fourie
Reveiwed By: Jonathan Byrne

BBS-1011
"Auto Workflow Assignment: When a document is move from within KTE to the assigned linked folder the correct worklfow is not initiated."
Moved the triggers into the document util copy action, fixes both webdav and KT tools.

Committed by: Megan Watson
Reviewed by: Conrad Vermeulen

KTS-2447
"Remove search dashets"
Updated. Removed general metadata dashlet.

Commited By: Conrad Vermeulen
Reviewed By: Kevin Fourie

KTS-2447
"Remove search dashets"
Updated. Removed search dashlet.

Commited By: Conrad Vermeulen
Reviewed By: Kevin Fourie

KTS-2454
"Search portlet must be expanded"
Fixed.

Committed By: Conrad Vermeulen
Reviewed By: Kevin Fourie

WSA-47
"Add Web Service Delphi Contribution"
Added.

Contributed By: Bjarte Kalstveit Vebjørnsen
Committed By: Conrad Vermeulen
Reviewed By: Kevin Fourie

KTS-2093
"When clicking on a large "Tag Cloud", more than one page of document attached to it, you get an error."
Fixed. Added a fixed line on line 108

Committed By: Jalaloedien Abrahams
Reviewed By: Conrad Vermeulen

KTS-2460
"Allow reindexing of knowledgetree tables"
Added.

Committed By: Conrad Vermeulen
Reviewed By: Kevin Fourie

KTS-2388
"Issue with detection of kt root in Suse Linux"
Contribution.

Committed By: Conrad Vermeulen
Reviewed By: Kevin Fourie

KTS-2429
"config.ini must be updated during upgrade for new search to work."
In Progress. Added class to help with ini editing.

Committed By: Kevin Fourie
Reviewed By: Conrad Vermeulen


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/STABLE/trunk@7328 c91229c3-7414-0410-bfa2-8a42b809f60b
bin/recreateIndexes.php 0 → 100644
  1 +<?php
  2 +
  3 +/**
  4 + * $Id
  5 + *
  6 + * The contents of this file are subject to the KnowledgeTree Public
  7 + * License Version 1.1.2 ("License"); You may not use this file except in
  8 + * compliance with the License. You may obtain a copy of the License at
  9 + * http://www.knowledgetree.com/KPL
  10 + *
  11 + * Software distributed under the License is distributed on an "AS IS"
  12 + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing rights and
  14 + * limitations under the License.
  15 + *
  16 + * All copies of the Covered Code must include on each user interface screen:
  17 + * (i) the "Powered by KnowledgeTree" logo and
  18 + * (ii) the KnowledgeTree copyright notice
  19 + * in the same form as they appear in the distribution. See the License for
  20 + * requirements.
  21 + *
  22 + * The Original Code is: KnowledgeTree Open Source
  23 + *
  24 + * The Initial Developer of the Original Code is The Jam Warehouse Software
  25 + * (Pty) Ltd, trading as KnowledgeTree.
  26 + * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright
  27 + * (C) 2007 The Jam Warehouse Software (Pty) Ltd;
  28 + * All Rights Reserved.
  29 + * Contributor( s): ______________________________________
  30 + *
  31 + */
  32 +
  33 +/*
  34 + * PURPOSE: This script will recreate the indexes on the database. It will also attempt to add foreign key constraints.
  35 + *
  36 + * NOTE: It was developed on mysql 5, so there may be a requirement for this to be running!
  37 + * NOTE: This assumes that the db is in the 3.5.0 state!
  38 + *
  39 + * It will produce 'errors' when there are issues. Many may be ignored as some do not apply to open source.
  40 + */
  41 +
  42 +require_once('../config/dmsDefaults.php');
  43 +
  44 +print _kt('Recreate DB Indexes') . "...\n\n";
  45 +
  46 +$recreator = new IndexRecreator();
  47 +$recreator->globalStart();
  48 +
  49 +do
  50 +{
  51 + $dropped = $recreator->dropIndexes();
  52 +} while ($dropped != 0);
  53 +
  54 +$recreator->applyPreFixes();
  55 +$recreator->addPrimaryKeys();
  56 +$recreator->addForeignKeys();
  57 +$recreator->removeDuplicateIndexes();
  58 +$recreator->addOtherIndexes();
  59 +$recreator->applyPostFixes();
  60 +
  61 +print sprintf(_kt('Total time: %s'), $recreator->globalEnd());
  62 +
  63 +print _kt('Done.') . "\n";
  64 +exit;
  65 +
  66 +class IndexRecreator
  67 +{
  68 + var $knownKeys;
  69 + var $knownPrimary;
  70 + var $newPrimary;
  71 + var $newKeys;
  72 + var $exec;
  73 + var $debugSQL = false;
  74 + var $verbose = true;
  75 +
  76 + var $foreignkeys;
  77 + var $primary;
  78 + var $globalstart;
  79 + var $start;
  80 +
  81 + function microtimeFloat()
  82 + {
  83 + list($usec, $sec) = explode(" ", microtime());
  84 + return ((float)$usec + (float)$sec);
  85 + }
  86 +
  87 + function globalStart()
  88 + {
  89 + $this->globalstart = $this->microtimeFloat();
  90 + }
  91 +
  92 + function start()
  93 + {
  94 + $this->start = $this->microtimeFloat();
  95 + }
  96 +
  97 + function globalEnd()
  98 + {
  99 + $time = $this->microtimeFloat() - $this->globalstart;
  100 +
  101 + return number_format($time,2,'.',',') . 's';
  102 + }
  103 +
  104 + function end()
  105 + {
  106 + $time = $this->microtimeFloat() - $this->start;
  107 + return number_format($time,2,'.',',') . "s";
  108 + }
  109 +
  110 + function IndexRecreator()
  111 + {
  112 + $this->knownKeys = array();
  113 + $this->knownPrimary = array();
  114 + $this->newPrimary = array();
  115 + $this->newKeys = array();
  116 + $this->exec = true;
  117 + }
  118 +
  119 + function applyPreFixes()
  120 + {
  121 +
  122 + }
  123 +
  124 + function addForeignKeys()
  125 + {
  126 + $this->addForeignKey('active_sessions', 'user_id', 'users', 'id');
  127 +
  128 + $this->addForeignKey('archive_restoration_request', 'document_id', 'documents', 'id');
  129 + $this->addForeignKey('archive_restoration_request', 'request_user_id', 'users', 'id');
  130 + $this->addForeignKey('archive_restoration_request', 'admin_user_id', 'users', 'id');
  131 +
  132 + $this->addForeignKey('archiving_settings', 'archiving_type_id', 'archiving_type_lookup', 'id');
  133 + $this->addForeignKey('archiving_settings', 'time_period_id', 'time_period', 'id');
  134 +
  135 + $this->addForeignKey('baobab_user_keys', 'user_id', 'users', 'id');
  136 + $this->addForeignKey('baobab_user_keys', 'key_id', 'baobab_keys', 'id');
  137 +
  138 + $this->addForeignKey('comment_searchable_text', 'comment_id', 'discussion_comments', 'id');
  139 + $this->addForeignKey('comment_searchable_text', 'document_id', 'documents', 'id');
  140 +
  141 + $this->addForeignKey('dashlet_disables', 'user_id', 'users', 'id');
  142 +
  143 + $this->addForeignKey('discussion_comments', 'thread_id', 'discussion_threads', 'id');
  144 + $this->addForeignKey('discussion_comments', 'user_id', 'users', 'id');
  145 + $this->addForeignKey('discussion_comments', 'in_reply_to', 'discussion_comments', 'id');
  146 +
  147 + $this->addForeignKey('discussion_threads', 'document_id', 'documents', 'id');
  148 +
  149 + $this->addForeignKey('document_archiving_link', 'document_id', 'documents', 'id');
  150 + $this->addForeignKey('document_archiving_link', 'archiving_settings_id', 'archiving_settings', 'id');
  151 +
  152 + $this->addForeignKey('document_content_version', 'document_id', 'documents', 'id');
  153 + $this->addForeignKey('document_content_version', 'mime_id', 'mime_types', 'id');
  154 +
  155 + $this->addForeignKey('document_fields','parent_fieldset','fieldsets','id');
  156 +
  157 + $this->addForeignKey('document_fields_link','document_field_id','document_fields','id');
  158 + $this->addForeignKey('document_fields_link','metadata_version_id','document_metadata_version','id');
  159 +
  160 + $this->addForeignKey('document_link','parent_document_id', 'documents', 'id');
  161 + $this->addForeignKey('document_link','child_document_id', 'documents', 'id');
  162 + $this->addForeignKey('document_link','link_type_id','document_link_types','id');
  163 +
  164 + $this->addForeignKey('document_metadata_version','document_type_id','document_types_lookup','id');
  165 + $this->addForeignKey('document_metadata_version','status_id','status_lookup','id');
  166 + $this->addForeignKey('document_metadata_version','document_id','documents','id');
  167 + $this->addForeignKey('document_metadata_version','version_creator_id','users','id');
  168 + $this->addForeignKey('document_metadata_version','content_version_id','document_content_version','id');
  169 + $this->addForeignKey('document_metadata_version','workflow_id','workflows','id');
  170 + $this->addForeignKey('document_metadata_version','workflow_state_id','workflow_states','id');
  171 +
  172 + $this->addForeignKey('document_role_allocations','role_id','roles','id');
  173 + $this->addForeignKey('document_role_allocations','permission_descriptor_id','permission_descriptors','id');
  174 +
  175 + $this->addForeignKey('document_searchable_text','document_id','documents','id');
  176 +
  177 + $this->addForeignKey('document_subscriptions','user_id','users','id');
  178 + $this->addForeignKey('document_subscriptions','document_id','documents','id');
  179 +
  180 + $this->addForeignKey('document_tags','document_id','documents','id');
  181 + $this->addForeignKey('document_tags','tag_id','tag_words','id');
  182 +
  183 + $this->addForeignKey('document_text','document_id','documents','id');
  184 +
  185 +
  186 + $this->addForeignKey('document_transaction_text','document_id','documents','id');
  187 +
  188 + $this->addForeignKey('document_transactions','document_id','documents','id', 'SET NULL', 'SET NULL');
  189 + $this->addForeignKey('document_transactions','user_id','users','id', 'SET NULL', 'SET NULL');
  190 +
  191 + $this->addForeignKey('document_type_fields_link','document_type_id', 'document_types_lookup','id');
  192 + $this->addForeignKey('document_type_fields_link','field_id','document_fields','id');
  193 +
  194 + $this->addForeignKey('document_type_fieldsets_link','document_type_id', 'document_types_lookup','id');
  195 + $this->addForeignKey('document_type_fieldsets_link','fieldset_id','fieldsets','id');
  196 +
  197 + $this->addForeignKey('documents','creator_id','users','id', 'SET NULL', 'SET NULL');
  198 + $this->addForeignKey('documents','folder_id','folders','id'); // we don't want this
  199 + $this->addForeignKey('documents','checked_out_user_id','users','id', 'SET NULL', 'SET NULL');
  200 + $this->addForeignKey('documents','status_id','status_lookup','id');
  201 + $this->addForeignKey('documents','permission_object_id','permission_objects','id');
  202 + $this->addForeignKey('documents','permission_lookup_id','permission_lookups','id');
  203 + $this->addForeignKey('documents','modified_user_id','users','id', 'SET NULL', 'SET NULL');
  204 + $this->addForeignKey('documents','metadata_version_id','document_metadata_version','id');
  205 +
  206 + $this->addForeignKey('download_files','document_id','documents','id');
  207 +
  208 + $this->addForeignKey('field_behaviour_options','behaviour_id','field_behaviours','id');
  209 + $this->addForeignKey('field_behaviour_options','field_id','document_fields','id');
  210 + $this->addForeignKey('field_behaviour_options','instance_id','field_value_instances','id');
  211 +
  212 + $this->addForeignKey('field_behaviours','field_id','document_fields','id');
  213 +
  214 + $this->addForeignKey('field_orders','child_field_id','document_fields','id');
  215 + $this->addForeignKey('field_orders','parent_field_id','document_fields','id');
  216 + $this->addForeignKey('field_orders','fieldset_id','fieldsets','id');
  217 +
  218 + $this->addForeignKey('field_value_instances','field_value_id','metadata_lookup','id'); // it is so.. strange ;)
  219 + $this->addForeignKey('field_value_instances','behaviour_id','field_behaviours','id');
  220 + $this->addForeignKey('field_value_instances','field_id','document_fields','id');
  221 +
  222 + $this->addForeignKey('fieldsets','master_field','document_fields','id');
  223 +
  224 + $this->addForeignKey('folder_doctypes_link','folder_id','folders','id');
  225 + $this->addForeignKey('folder_doctypes_link','document_type_id','document_types_lookup','id');
  226 +
  227 + $this->addForeignKey('folder_searchable_text','folder_id','folders','id');
  228 +
  229 + $this->addForeignKey('folder_subscriptions','user_id','users','id');
  230 + $this->addForeignKey('folder_subscriptions','folder_id','folders','id');
  231 +
  232 + $this->addForeignKey('folder_transactions','folder_id','folders','id', 'SET NULL', 'SET NULL');
  233 + $this->addForeignKey('folder_transactions','user_id','users','id', 'SET NULL', 'SET NULL');
  234 +
  235 + $this->addForeignKey('folder_workflow_map','folder_id', 'folders','id');
  236 + $this->addForeignKey('folder_workflow_map','workflow_id', 'workflows','id');
  237 +
  238 + $this->addForeignKey('folders','creator_id','users','id');
  239 + $this->addForeignKey('folders','permission_object_id','permission_objects','id');
  240 + $this->addForeignKey('folders','permission_lookup_id','permission_lookups','id');
  241 +// $this->addForeignKey('folders','parent_id','folders','id'); // cant do this because of root that is 0... need to make it null!
  242 +
  243 + $this->addForeignKey('folders_users_roles_link','user_id','users','id');
  244 + $this->addForeignKey('folders_users_roles_link','document_id','documents','id');
  245 +
  246 + $this->addForeignKey('groups_groups_link','parent_group_id','groups_lookup','id');
  247 + $this->addForeignKey('groups_groups_link','member_group_id','groups_lookup','id');
  248 +
  249 + $this->addForeignKey('groups_lookup','unit_id', 'units_lookup','id');
  250 +
  251 + $this->addForeignKey('index_files','document_id','documents','id');
  252 + $this->addForeignKey('index_files','user_id','users','id');
  253 +
  254 + $this->addForeignKey('metadata_lookup','document_field_id','document_fields','id');
  255 +// $this->addForeignKey('metadata_lookup','treeorg_parent','??','id');
  256 +
  257 + $this->addForeignKey('metadata_lookup_tree','document_field_id', 'document_fields','id');
  258 +// $this->addForeignKey('metadata_lookup_tree','metadata_lookup_tree_parent', '??','id');
  259 +
  260 + $this->addForeignKey('mime_types','mime_document_id','mime_documents','id');
  261 +
  262 + $this->addForeignKey('news','image_mime_type_id','mime_types','id');
  263 +
  264 + $this->addForeignKey('notifications','user_id', 'users','id');
  265 +
  266 + $this->addForeignKey('permission_assignments','permission_id', 'permissions','id');
  267 + $this->addForeignKey('permission_assignments','permission_object_id','permission_objects','id'); // duplicate
  268 + $this->addForeignKey('permission_assignments','permission_descriptor_id','permission_descriptors','id');
  269 +
  270 + $this->addForeignKey('permission_descriptor_groups','descriptor_id','permission_descriptors','id');
  271 + $this->addForeignKey('permission_descriptor_groups','group_id','groups_lookup','id');
  272 +
  273 + $this->addForeignKey('permission_descriptor_roles','descriptor_id','permission_descriptors','id');
  274 + $this->addForeignKey('permission_descriptor_roles','role_id','roles','id');
  275 +
  276 + $this->addForeignKey('permission_descriptor_users','descriptor_id','permission_descriptors','id');
  277 + $this->addForeignKey('permission_descriptor_users','user_id','users','id');
  278 +
  279 + $this->addForeignKey('permission_dynamic_assignments','dynamic_condition_id','permission_dynamic_conditions','id');
  280 + $this->addForeignKey('permission_dynamic_assignments','permission_id','permissions','id');
  281 +
  282 + $this->addForeignKey('permission_dynamic_conditions','permission_object_id','permission_objects','id');
  283 + $this->addForeignKey('permission_dynamic_conditions','group_id','groups_lookup','id');
  284 + $this->addForeignKey('permission_dynamic_conditions','condition_id','saved_searches','id');
  285 +
  286 + $this->addForeignKey('permission_lookup_assignments','permission_id','permissions','id');
  287 + $this->addForeignKey('permission_lookup_assignments','permission_lookup_id','permission_lookups','id'); // duplicate
  288 + $this->addForeignKey('permission_lookup_assignments','permission_descriptor_id','permission_descriptors','id');
  289 +
  290 + $this->addForeignKey('plugin_rss','user_id','users','id');
  291 +
  292 + $this->addForeignKey('quicklinks','user_id','users','id');
  293 +
  294 + $this->addForeignKey('role_allocations','folder_id','folders','id');
  295 + $this->addForeignKey('role_allocations','role_id', 'roles','id');
  296 + $this->addForeignKey('role_allocations','permission_descriptor_id','permission_descriptors','id');
  297 +
  298 + $this->addForeignKey('saved_searches','user_id','users','id');
  299 +
  300 + $this->addForeignKey('search_document_user_link','document_id','documents','id');
  301 + $this->addForeignKey('search_document_user_link','user_id','users','id');
  302 +
  303 + $this->addForeignKey('search_saved','user_id','users','id');
  304 + $this->addForeignKey('search_saved_events','document_id','documents','id');
  305 +
  306 + $this->addForeignKey('time_period','time_unit_id','time_unit_lookup','id');
  307 +
  308 + $this->addForeignKey('type_workflow_map','document_type_id','document_types_lookup','id');
  309 + $this->addForeignKey('type_workflow_map','workflow_id','workflows','id');
  310 +
  311 + $this->addForeignKey('units_lookup','folder_id','folders','id');
  312 +
  313 + $this->addForeignKey('units_organisations_link','unit_id','units_lookup','id');
  314 + $this->addForeignKey('units_organisations_link','organisation_id','organisations_lookup','id');
  315 +
  316 + $this->addForeignKey('uploaded_files','userid','users','id');
  317 + $this->addForeignKey('uploaded_files','document_id','documents','id');
  318 +
  319 + $this->addForeignKey('user_history','user_id','users','id');
  320 +
  321 + $this->addForeignKey('users','authentication_source_id','authentication_sources','id');
  322 +
  323 + $this->addForeignKey('users_groups_link', 'user_id','users','id');
  324 + $this->addForeignKey('users_groups_link', 'group_id','groups_lookup', 'id');
  325 +
  326 + $this->addForeignKey('workflow_documents','document_id', 'documents','id');
  327 + $this->addForeignKey('workflow_documents','workflow_id', 'workflows','id');
  328 + $this->addForeignKey('workflow_documents','state_id','workflow_states','id');
  329 +
  330 + $this->addForeignKey('workflow_state_actions','state_id','workflow_states','id');
  331 +
  332 + $this->addForeignKey('workflow_state_disabled_actions','state_id','workflow_states','id');
  333 +
  334 + $this->addForeignKey('workflow_state_permission_assignments','permission_id','permissions','id');
  335 + $this->addForeignKey('workflow_state_permission_assignments','permission_descriptor_id','permission_descriptors','id');
  336 + $this->addForeignKey('workflow_state_permission_assignments','workflow_state_id','workflow_states','id');
  337 +
  338 + $this->addForeignKey('workflow_state_transitions','state_id','workflow_states','id');
  339 + $this->addForeignKey('workflow_state_transitions','transition_id','workflow_transitions','id');
  340 +
  341 + $this->addForeignKey('workflow_states','workflow_id', 'workflows','id');
  342 + $this->addForeignKey('workflow_states','inform_descriptor_id', 'permission_descriptors','id');
  343 +
  344 + $this->addForeignKey('workflow_transitions','workflow_id','workflows','id');
  345 + $this->addForeignKey('workflow_transitions','target_state_id','workflow_states','id');
  346 + $this->addForeignKey('workflow_transitions','guard_permission_id','permissions','id');
  347 + $this->addForeignKey('workflow_transitions','guard_condition_id','saved_searches','id');
  348 + $this->addForeignKey('workflow_transitions','guard_group_id','groups_lookup','id');
  349 + $this->addForeignKey('workflow_transitions','guard_role_id','roles','id');
  350 +
  351 + $this->addForeignKey('workflow_trigger_instances','workflow_transition_id','workflow_transitions','id');
  352 +
  353 + $this->addForeignKey('workflows','start_state_id','workflow_states','id');
  354 +
  355 + }
  356 +
  357 + function removeDuplicateIndexes()
  358 + {
  359 + foreach($this->primary as $table=>$key)
  360 + {
  361 + $this->dropIndex($table,$key);
  362 + }
  363 +
  364 + }
  365 + function addOtherIndexes()
  366 + {
  367 + $this->addIndex('active_sessions', 'session_id');
  368 + $this->addIndex('authentication_sources','namespace');
  369 +
  370 + $this->addIndex('column_entries','view_namespace');
  371 +
  372 + $this->addIndex('comment_searchable_text', 'body', 'FULLTEXT');
  373 +
  374 +
  375 + $this->addIndex('dashlet_disables','dashlet_namespace');
  376 + $this->addIndex('document_content_version','storage_path');
  377 +
  378 + $this->addIndex('document_metadata_version','version_created');
  379 + $this->addIndex('document_role_allocations', array('document_id', 'role_id'));
  380 +
  381 + $this->addIndex('document_searchable_text','document_text', 'FULLTEXT');
  382 +
  383 + $this->addIndex('document_text','document_text', 'FULLTEXT');
  384 + $this->addIndex('document_transaction_text','document_text', 'FULLTEXT');
  385 +
  386 + $this->addIndex('document_transaction_types_lookup','namespace', 'UNIQUE');
  387 +
  388 + $this->addIndex('document_transactions','session_id');
  389 +
  390 + $this->addIndex('document_types_lookup','name');
  391 + //$this->addIndex('document_types_lookup','disabled'); ? used
  392 +
  393 + $this->addIndex('documents','created');
  394 +
  395 + $this->addIndex('field_behaviour_options',array('behaviour_id','field_id'));
  396 +
  397 + $this->addIndex('field_behaviours','name');
  398 +
  399 + $this->addIndex('fieldsets','is_generic');
  400 + $this->addIndex('fieldsets','is_complete');
  401 + $this->addIndex('fieldsets','is_system');
  402 +
  403 + $this->addIndex('folder_searchable_text','folder_text' ,'FULLTEXT');
  404 +
  405 + $this->addIndex('folder_transactions','session_id');
  406 +
  407 + $this->addIndex('folders','name');
  408 + $this->addIndex('folders', array('parent_id','name'));
  409 +
  410 + $this->addIndex('groups_lookup','name');
  411 + $this->addIndex('groups_lookup', array('authentication_source_id','authentication_details_s1'));
  412 +
  413 + $this->addIndex('interceptor_instances','interceptor_namespace'); // unique?
  414 +
  415 + $this->addIndex('metadata_lookup','disabled');
  416 + //$this->addNewIndex('metadata_lookup','is_stuck'); don't think this is used anywhere....
  417 +
  418 + $this->addIndex('metadata_lookup_tree','metadata_lookup_tree_parent');
  419 +
  420 + $this->addIndex('mime_types','filetypes'); // should be unique...
  421 + $this->addIndex('mime_types','mimetypes');
  422 +
  423 + $this->addIndex('notifications','data_int_1'); // document id seems to be stored in this. used by clearnotifications.
  424 +// $this->addIndex('notifications','type'); // don't think this is used
  425 +
  426 + $this->addIndex('organisations_lookup','name', 'UNIQUE');
  427 +
  428 + $this->addIndex('permission_assignments', array('permission_object_id','permission_id'), 'UNIQUE'); // note change of order
  429 +// $this->dropIndex('permission_assignments','permission_object_id'); // duplicate
  430 +
  431 + //$this->dropIndex('permission_descriptor_groups','descriptor_id'); // in primary key
  432 + $this->addIndex('permission_descriptor_groups','group_id');
  433 +
  434 + //$this->dropIndex('permission_descriptor_roles','descriptor_id'); // in primary key
  435 + $this->addIndex('permission_descriptor_roles','role_id');
  436 +
  437 + //$this->dropIndex('permission_descriptor_users','descriptor_id'); // in primary
  438 + $this->addIndex('permission_descriptor_users','user_id');
  439 +
  440 + $this->addIndex('permission_descriptors','descriptor');
  441 +
  442 + $this->addIndex('permission_lookup_assignments', array('permission_lookup_id', 'permission_id'));
  443 + //$this->dropIndex('permission_lookup_assignments','permission_lookup_id'); // in composite
  444 +
  445 + $this->addIndex('permissions','name', 'UNIQUE');
  446 +
  447 + $this->addIndex('plugins','namespace','UNIQUE');
  448 + $this->addIndex('plugins','disabled');
  449 +
  450 + $this->addIndex('quicklinks','target_id');
  451 +
  452 + $this->addIndex('roles','name','UNIQUE');
  453 + $this->addIndex('saved_searches','namespace','UNIQUE');
  454 +
  455 + $this->addIndex('system_settings','name', 'UNIQUE');
  456 +
  457 + $this->addIndex('units_lookup','name' ,'UNIQUE');
  458 + $this->dropIndex('units_lookup','folder_id');
  459 + $this->addIndex('units_lookup','folder_id' ,'UNIQUE');
  460 +
  461 + $this->addIndex('upgrades','descriptor');
  462 + $this->addIndex('upgrades','parent');
  463 +
  464 + $this->addIndex('user_history','action_namespace');
  465 + $this->addIndex('user_history','datetime');
  466 + $this->addIndex('user_history','session_id');
  467 +
  468 + $this->addIndex('user_history_documents', array('user_id','document_id'));
  469 + //$this->dropIndex('user_history_documents', 'user_id'); // duplicate
  470 +
  471 + $this->addIndex('user_history_folders', array('user_id','folder_id'));
  472 + //$this->dropIndex('user_history_folders', 'user_id'); // duplicate
  473 +
  474 + $this->addIndex('users','username' ,'UNIQUE');
  475 + $this->addIndex('users','authentication_source_id');
  476 + //$this->addNewIndex('users','authentication_details_b1');
  477 + //$this->addNewIndex('users','authentication_details_b2');
  478 + $this->addIndex('users','last_login');
  479 + $this->addIndex('users','disabled');
  480 +
  481 + $this->addIndex('workflow_states','name');
  482 + $this->addIndex('workflow_states','inform_descriptor_id'); //?
  483 +
  484 + $this->addIndex('workflow_transitions',array('workflow_id','name'), 'UNIQUE');
  485 + //$this->dropIndex('workflow_transitions','workflow_id'); // duplicate
  486 + $this->addIndex('workflow_transitions','name');
  487 + $this->addIndex('workflow_transitions','guard_permission_id'); //?
  488 +
  489 + $this->addIndex('workflow_trigger_instances','namespace');
  490 +
  491 + $this->addIndex('workflows','name');
  492 +
  493 +
  494 + }
  495 +
  496 + function applyPostFixes()
  497 + {
  498 +
  499 + }
  500 +
  501 + function dropIndex($table, $field)
  502 + {
  503 + if (!is_array($fields)) $field = array($field);
  504 + $field = implode('_', $field);
  505 + $sql = "alter table $table drop index $field";
  506 + $this->_exec($sql);
  507 + }
  508 +
  509 + function addIndex($table, $fields, $type='')
  510 + {
  511 + if (!is_array($fields)) $fields = array($fields);
  512 + $index = implode('_', $fields);
  513 + //$index = str_replace('_id','',$index);
  514 + $fields = implode(',',$fields);
  515 + $sql = "alter table $table add $type index $index ($fields) ";
  516 + $this->_exec($sql);
  517 + }
  518 +
  519 + function addForeignKey($table, $field, $othertable, $otherfield, $ondelete='cascade', $onupdate='cascade')
  520 + {
  521 + $sql = "alter table $table add foreign key ($field) references $othertable ($otherfield) ";
  522 + if ($ondelete != '')
  523 + $sql .= " on delete $ondelete";
  524 + if ($onupdate != '')
  525 + $sql .= " on update $onupdate";
  526 + $this->_exec($sql);
  527 + }
  528 +
  529 + function addPrimaryKeys()
  530 + {
  531 + $this->addPrimaryKey('active_sessions', 'id');
  532 + $this->addPrimaryKey('archive_restoration_request','id');
  533 + $this->addPrimaryKey('archiving_settings','id');
  534 + $this->addPrimaryKey('archiving_type_lookup','id');
  535 + $this->addPrimaryKey('authentication_sources','id');
  536 + $this->addPrimaryKey('baobab_keys','id');
  537 + $this->addPrimaryKey('baobab_user_keys','id');
  538 + $this->addPrimaryKey('column_entries','id');
  539 + $this->addPrimaryKey('comment_searchable_text','comment_id');
  540 + $this->addPrimaryKey('dashlet_disables','id');
  541 + $this->addPrimaryKey('data_types','id');
  542 + $this->addPrimaryKey('discussion_comments','id');
  543 + $this->addPrimaryKey('discussion_threads','id');
  544 + $this->addPrimaryKey('document_archiving_link','id');
  545 + $this->addPrimaryKey('document_content_version','id');
  546 + $this->addPrimaryKey('document_fields','id');
  547 + $this->addPrimaryKey('document_fields_link','id');
  548 + $this->addPrimaryKey('document_incomplete','id');
  549 + $this->addPrimaryKey('document_link','id');
  550 + $this->addPrimaryKey('document_link_types','id');
  551 + $this->addPrimaryKey('document_metadata_version','id');
  552 + $this->addPrimaryKey('document_role_allocations','id');
  553 + $this->addPrimaryKey('document_subscriptions','id');
  554 + $this->addPrimaryKey('document_tags',array('document_id','tag_id'));
  555 + $this->addPrimaryKey('document_text', 'document_id');
  556 + $this->addPrimaryKey('document_transaction_types_lookup', 'id');
  557 + $this->addPrimaryKey('document_transaction_text', 'document_id');
  558 + $this->addPrimaryKey('document_transaction_types_lookup','id');
  559 + $this->addPrimaryKey('document_transactions','id');
  560 + $this->addPrimaryKey('document_type_fields_link','id');
  561 + $this->addPrimaryKey('document_type_fieldsets_link','id');
  562 + $this->addPrimaryKey('document_types_lookup','id');
  563 + $this->addPrimaryKey('documents','id');
  564 + $this->addPrimaryKey('download_files',array('document_id','session'));
  565 + $this->addPrimaryKey('field_behaviours','id');
  566 + $this->addPrimaryKey('field_value_instances','id');
  567 + $this->addPrimaryKey('fieldsets','id');
  568 + $this->addPrimaryKey('folder_doctypes_link','id');
  569 + $this->addPrimaryKey('folder_searchable_text','folder_id');
  570 + $this->addPrimaryKey('folder_subscriptions','id');
  571 + $this->addPrimaryKey('folder_transactions','id');
  572 + $this->addPrimaryKey('folder_workflow_map','folder_id');
  573 + $this->addPrimaryKey('folders','id');
  574 + $this->addPrimaryKey('folders_users_roles_link','id');
  575 + $this->addPrimaryKey('groups_groups_link','id');
  576 + $this->addPrimaryKey('groups_lookup','id');
  577 + $this->addPrimaryKey('help','id');
  578 + $this->addPrimaryKey('help_replacement','id');
  579 + $this->addPrimaryKey('interceptor_instances','id');
  580 + $this->addPrimaryKey('links','id');
  581 + $this->addPrimaryKey('metadata_lookup','id');
  582 + $this->addPrimaryKey('metadata_lookup_tree','id');
  583 + $this->addPrimaryKey('mime_documents','id');
  584 + $this->addPrimaryKey('mime_types','id');
  585 + $this->addPrimaryKey('news','id');
  586 + $this->addPrimaryKey('notifications','id');
  587 + $this->addPrimaryKey('organisations_lookup','id');
  588 + $this->addPrimaryKey('permission_assignments','id');
  589 + $this->addPrimaryKey('permission_descriptor_groups', array('descriptor_id','group_id'));
  590 + $this->addPrimaryKey('permission_descriptor_roles', array('descriptor_id','role_id'));
  591 + $this->addPrimaryKey('permission_descriptor_users', array('descriptor_id','user_id'));
  592 + $this->addPrimaryKey('permission_descriptors','id');
  593 + $this->addPrimaryKey('permission_dynamic_conditions','id');
  594 + $this->addPrimaryKey('permission_lookup_assignments','id');
  595 + $this->addPrimaryKey('permission_lookups','id');
  596 + $this->addPrimaryKey('permission_objects','id');
  597 + $this->addPrimaryKey('permissions','id');
  598 + $this->addPrimaryKey('plugin_rss','id');
  599 + $this->addPrimaryKey('plugins','id');
  600 + $this->addPrimaryKey('quicklinks','id');
  601 + $this->addPrimaryKey('role_allocations','id');
  602 + $this->addPrimaryKey('roles','id');
  603 + $this->addPrimaryKey('saved_searches','id');
  604 + $this->addPrimaryKey('scheduler_tasks','id');
  605 + $this->addPrimaryKey('search_ranking',array('groupname','itemname'));
  606 + $this->addPrimaryKey('search_saved','id');
  607 + $this->addPrimaryKey('search_saved_events','document_id');
  608 + $this->addPrimaryKey('status_lookup','id');
  609 + $this->addPrimaryKey('system_settings','id');
  610 + $this->addPrimaryKey('tag_words','id');
  611 + $this->addPrimaryKey('time_period','id');
  612 + $this->addPrimaryKey('time_unit_lookup','id');
  613 + $this->addPrimaryKey('trigger_selection','event_ns');
  614 + $this->addPrimaryKey('type_workflow_map','document_type_id');
  615 + $this->addPrimaryKey('units_lookup','id');
  616 + $this->addPrimaryKey('units_organisations_link','id');
  617 + $this->addPrimaryKey('upgrades','id');
  618 + $this->addPrimaryKey('uploaded_files','tempfilename');
  619 + $this->addPrimaryKey('user_history','id');
  620 + $this->addPrimaryKey('user_history_documents','id');
  621 + $this->addPrimaryKey('user_history_folders','id');
  622 + $this->addPrimaryKey('users','id');
  623 + $this->addPrimaryKey('users_groups_link','id');
  624 + $this->addPrimaryKey('workflow_actions','workflow_id');
  625 + $this->addPrimaryKey('workflow_documents','document_id');
  626 + $this->addPrimaryKey('workflow_state_permission_assignments','id');
  627 + $this->addPrimaryKey('workflow_states','id');
  628 + $this->addPrimaryKey('workflow_transitions','id');
  629 + $this->addPrimaryKey('workflow_trigger_instances','id');
  630 + $this->addPrimaryKey('workflows','id');
  631 + }
  632 +
  633 + function addPrimaryKey($table, $primarykey)
  634 + {
  635 + if (is_array($primarykey))
  636 + {
  637 + $primarykey = implode(',', $primarykey);
  638 + }
  639 +
  640 + $sql="alter table $table add primary key ($primarykey)";
  641 + $this->_exec($sql, false);
  642 +
  643 + if (strpos($primarykey,',') === false)
  644 + {
  645 + $this->primary[$table] = $primarykey;
  646 + $sql="alter table $table add unique key ($primarykey)";
  647 + $this->_exec($sql);
  648 + }
  649 + }
  650 +
  651 + function dropIndexes()
  652 + {
  653 + $result = DBUtil::getResultArray("show tables");
  654 + $tables=array();
  655 +
  656 + foreach($result as $table)
  657 + {
  658 + $keys = array_keys($table);
  659 +
  660 + $tablename = $table[$keys[0]];
  661 + if (substr($tablename,0,5) == 'zseq_')
  662 + {
  663 + continue;
  664 + }
  665 +
  666 + $stmt = DBUtil::getResultArray("show create table $tablename");
  667 +
  668 + $keys = array_keys($stmt[0]);
  669 +
  670 + $sql = $stmt[0][$keys[1]];
  671 +
  672 + $table = array('fks'=>array(), 'pk'=>array(), 'keys'=>array());
  673 + $lines = explode("\n", $sql);
  674 + foreach($lines as $line)
  675 + {
  676 + $line = trim($line);
  677 + if (strpos($line, 'PRIMARY KEY') === 0)
  678 + {
  679 + preg_match('(\`([^\`])*\`)',$line, $params);
  680 + $primaryKey = explode(',', $params[0]);
  681 + foreach($primaryKey as $value)
  682 + {
  683 + $fieldname = substr($value,1,-1);
  684 + $table['pk'][] = $fieldname;
  685 + }
  686 + continue;
  687 + }
  688 + elseif (strpos($line, 'CONSTRAINT') === 0)
  689 + {
  690 + preg_match_all('(\`([^\`])*\`)',$line, $params);
  691 +
  692 + $fieldname = substr($params[0][1],1,-1);
  693 +
  694 + $table['fks'][$fieldname] = array(
  695 + 'constraint'=>substr($params[0][0],1,-1),
  696 + 'table'=>substr($params[0][2],1,-1),
  697 + 'field'=>substr($params[0][3],1,-1)
  698 + );
  699 + continue;
  700 + }
  701 + elseif (strpos($line, 'KEY') !== false)
  702 + {
  703 + preg_match_all('(\`([^\`])*\`)',$line, $params);
  704 + $fieldname = substr($params[0][1],1,-1);
  705 + $key = substr($params[0][0],1,-1);
  706 + $table['keys'][$fieldname] = array('name'=>$key, 'unique'=>false);
  707 + if (strpos($line, 'UNIQUE KEY') !== false)
  708 + {
  709 + if (count($params[0]) == 2)
  710 + {
  711 + $table['keys'][$fieldname]['unique']=true;
  712 + }
  713 + }
  714 + continue;
  715 + }
  716 + }
  717 +
  718 + $tables[$tablename]= $table;
  719 + }
  720 +
  721 + $dropped = 0;
  722 +
  723 + // drop foreign keys
  724 + foreach($tables as $tablename=>$table)
  725 + {
  726 + foreach($table['fks'] as $fieldname=>$constraint)
  727 + {
  728 + $name = $constraint['constraint'];
  729 + $table = $constraint['table'];
  730 + $field = $constraint['field'];
  731 + $sql = "ALTER TABLE $tablename DROP FOREIGN KEY $name;";
  732 + if ($this->_exec($sql)) $dropped++;
  733 + }
  734 + }
  735 +
  736 + // drop primary keys
  737 + foreach($tables as $tablename=>$table)
  738 + {
  739 + foreach($table['pk'] as $fieldname)
  740 + {
  741 + $sql = "ALTER TABLE $tablename DROP primary key;";
  742 + if ($this->_exec($sql,false)) $dropped++;
  743 + break;
  744 + }
  745 + }
  746 +
  747 + // drop normal indexes
  748 +
  749 + foreach($tables as $tablename=>$table)
  750 + {
  751 + foreach($table['keys'] as $fieldname=>$keyinfo)
  752 + {
  753 + $keyname = $keyinfo['name'];
  754 + $sql = "ALTER TABLE $tablename DROP key $keyname;";
  755 + if ($this->_exec($sql)) $dropped++;
  756 + break;
  757 + }
  758 + }
  759 +
  760 +
  761 + return $dropped;
  762 + }
  763 +
  764 + function _exec($sql, $report = true)
  765 + {
  766 + print "Action: $sql";
  767 + $this->start();
  768 + $rs = DBUtil::runQuery($sql);
  769 + print " - " . $this->end() . "\n";
  770 + if (PEAR::isError($rs))
  771 + {
  772 + if ($report) print "* " . $rs->getMessage() . "\n";
  773 + return false;
  774 + }
  775 + return true;
  776 + }
  777 +
  778 +}
  779 +
  780 +
  781 +?>
0 782 \ No newline at end of file
... ...
config/dmsDefaults.php
... ... @@ -27,7 +27,7 @@
27 27 * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright
28 28 * (C) 2007 The Jam Warehouse Software (Pty) Ltd;
29 29 * All Rights Reserved.
30   - * Contributor( s): ______________________________________
  30 + * Contributor( s): Guenter Roeck______________________________________
31 31 *
32 32 */
33 33  
... ... @@ -348,6 +348,10 @@ class KTInit {
348 348 if ($i === false) {
349 349 break;
350 350 }
  351 + if ($rootUrl)
  352 + {
  353 + $rootUrl .= '/';
  354 + }
351 355 $rootUrl .= substr($urlpath, 0, $i);
352 356 $urlpath = substr($urlpath, $i + 1);
353 357 }
... ...
ktwsapi/delphi/TODO.txt deleted
ktwsapi/delphi/doc/KTWSAPI.chm 0 → 100644
No preview for this file type
ktwsapi/delphi/examples/KTWSAPIExamples.bdsproj 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<BorlandProject>
  3 + <PersonalityInfo>
  4 + <Option>
  5 + <Option Name="Personality">Delphi.Personality</Option>
  6 + <Option Name="ProjectType">VCLApplication</Option>
  7 + <Option Name="Version">1.0</Option>
  8 + <Option Name="GUID">{A7B8ECC5-0F7B-4E7C-8C44-8356FDCDB36A}</Option>
  9 + </Option>
  10 + </PersonalityInfo>
  11 + <Delphi.Personality>
  12 + <Source>
  13 + <Source Name="MainSource">KTWSAPIExamples.dpr</Source>
  14 + </Source>
  15 + <FileVersion>
  16 + <FileVersion Name="Version">7.0</FileVersion>
  17 + </FileVersion>
  18 + <Compiler>
  19 + <Compiler Name="A">8</Compiler>
  20 + <Compiler Name="B">0</Compiler>
  21 + <Compiler Name="C">1</Compiler>
  22 + <Compiler Name="D">1</Compiler>
  23 + <Compiler Name="E">0</Compiler>
  24 + <Compiler Name="F">0</Compiler>
  25 + <Compiler Name="G">1</Compiler>
  26 + <Compiler Name="H">1</Compiler>
  27 + <Compiler Name="I">1</Compiler>
  28 + <Compiler Name="J">0</Compiler>
  29 + <Compiler Name="K">0</Compiler>
  30 + <Compiler Name="L">1</Compiler>
  31 + <Compiler Name="M">0</Compiler>
  32 + <Compiler Name="N">1</Compiler>
  33 + <Compiler Name="O">1</Compiler>
  34 + <Compiler Name="P">1</Compiler>
  35 + <Compiler Name="Q">0</Compiler>
  36 + <Compiler Name="R">0</Compiler>
  37 + <Compiler Name="S">0</Compiler>
  38 + <Compiler Name="T">0</Compiler>
  39 + <Compiler Name="U">0</Compiler>
  40 + <Compiler Name="V">1</Compiler>
  41 + <Compiler Name="W">0</Compiler>
  42 + <Compiler Name="X">1</Compiler>
  43 + <Compiler Name="Y">1</Compiler>
  44 + <Compiler Name="Z">1</Compiler>
  45 + <Compiler Name="ShowHints">True</Compiler>
  46 + <Compiler Name="ShowWarnings">True</Compiler>
  47 + <Compiler Name="UnitAliases">WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;</Compiler>
  48 + <Compiler Name="NamespacePrefix"></Compiler>
  49 + <Compiler Name="GenerateDocumentation">False</Compiler>
  50 + <Compiler Name="DefaultNamespace"></Compiler>
  51 + <Compiler Name="SymbolDeprecated">True</Compiler>
  52 + <Compiler Name="SymbolLibrary">True</Compiler>
  53 + <Compiler Name="SymbolPlatform">True</Compiler>
  54 + <Compiler Name="SymbolExperimental">True</Compiler>
  55 + <Compiler Name="UnitLibrary">True</Compiler>
  56 + <Compiler Name="UnitPlatform">True</Compiler>
  57 + <Compiler Name="UnitDeprecated">True</Compiler>
  58 + <Compiler Name="UnitExperimental">True</Compiler>
  59 + <Compiler Name="HResultCompat">True</Compiler>
  60 + <Compiler Name="HidingMember">True</Compiler>
  61 + <Compiler Name="HiddenVirtual">True</Compiler>
  62 + <Compiler Name="Garbage">True</Compiler>
  63 + <Compiler Name="BoundsError">True</Compiler>
  64 + <Compiler Name="ZeroNilCompat">True</Compiler>
  65 + <Compiler Name="StringConstTruncated">True</Compiler>
  66 + <Compiler Name="ForLoopVarVarPar">True</Compiler>
  67 + <Compiler Name="TypedConstVarPar">True</Compiler>
  68 + <Compiler Name="AsgToTypedConst">True</Compiler>
  69 + <Compiler Name="CaseLabelRange">True</Compiler>
  70 + <Compiler Name="ForVariable">True</Compiler>
  71 + <Compiler Name="ConstructingAbstract">True</Compiler>
  72 + <Compiler Name="ComparisonFalse">True</Compiler>
  73 + <Compiler Name="ComparisonTrue">True</Compiler>
  74 + <Compiler Name="ComparingSignedUnsigned">True</Compiler>
  75 + <Compiler Name="CombiningSignedUnsigned">True</Compiler>
  76 + <Compiler Name="UnsupportedConstruct">True</Compiler>
  77 + <Compiler Name="FileOpen">True</Compiler>
  78 + <Compiler Name="FileOpenUnitSrc">True</Compiler>
  79 + <Compiler Name="BadGlobalSymbol">True</Compiler>
  80 + <Compiler Name="DuplicateConstructorDestructor">True</Compiler>
  81 + <Compiler Name="InvalidDirective">True</Compiler>
  82 + <Compiler Name="PackageNoLink">True</Compiler>
  83 + <Compiler Name="PackageThreadVar">True</Compiler>
  84 + <Compiler Name="ImplicitImport">True</Compiler>
  85 + <Compiler Name="HPPEMITIgnored">True</Compiler>
  86 + <Compiler Name="NoRetVal">True</Compiler>
  87 + <Compiler Name="UseBeforeDef">True</Compiler>
  88 + <Compiler Name="ForLoopVarUndef">True</Compiler>
  89 + <Compiler Name="UnitNameMismatch">True</Compiler>
  90 + <Compiler Name="NoCFGFileFound">True</Compiler>
  91 + <Compiler Name="ImplicitVariants">True</Compiler>
  92 + <Compiler Name="UnicodeToLocale">True</Compiler>
  93 + <Compiler Name="LocaleToUnicode">True</Compiler>
  94 + <Compiler Name="ImagebaseMultiple">True</Compiler>
  95 + <Compiler Name="SuspiciousTypecast">True</Compiler>
  96 + <Compiler Name="PrivatePropAccessor">True</Compiler>
  97 + <Compiler Name="UnsafeType">False</Compiler>
  98 + <Compiler Name="UnsafeCode">False</Compiler>
  99 + <Compiler Name="UnsafeCast">False</Compiler>
  100 + <Compiler Name="OptionTruncated">True</Compiler>
  101 + <Compiler Name="WideCharReduced">True</Compiler>
  102 + <Compiler Name="DuplicatesIgnored">True</Compiler>
  103 + <Compiler Name="UnitInitSeq">True</Compiler>
  104 + <Compiler Name="LocalPInvoke">True</Compiler>
  105 + <Compiler Name="MessageDirective">True</Compiler>
  106 + <Compiler Name="CodePage"></Compiler>
  107 + </Compiler>
  108 + <Linker>
  109 + <Linker Name="MapFile">0</Linker>
  110 + <Linker Name="OutputObjs">0</Linker>
  111 + <Linker Name="GenerateHpps">False</Linker>
  112 + <Linker Name="ConsoleApp">1</Linker>
  113 + <Linker Name="DebugInfo">False</Linker>
  114 + <Linker Name="RemoteSymbols">False</Linker>
  115 + <Linker Name="GenerateDRC">False</Linker>
  116 + <Linker Name="MinStackSize">16384</Linker>
  117 + <Linker Name="MaxStackSize">1048576</Linker>
  118 + <Linker Name="ImageBase">4194304</Linker>
  119 + <Linker Name="ExeDescription"></Linker>
  120 + </Linker>
  121 + <Directories>
  122 + <Directories Name="OutputDir"></Directories>
  123 + <Directories Name="UnitOutputDir"></Directories>
  124 + <Directories Name="PackageDLLOutputDir"></Directories>
  125 + <Directories Name="PackageDCPOutputDir"></Directories>
  126 + <Directories Name="SearchPath"></Directories>
  127 + <Directories Name="Packages"></Directories>
  128 + <Directories Name="Conditionals"></Directories>
  129 + <Directories Name="DebugSourceDirs"></Directories>
  130 + <Directories Name="UsePackages">False</Directories>
  131 + </Directories>
  132 + <Parameters>
  133 + <Parameters Name="RunParams"></Parameters>
  134 + <Parameters Name="HostApplication"></Parameters>
  135 + <Parameters Name="Launcher"></Parameters>
  136 + <Parameters Name="UseLauncher">False</Parameters>
  137 + <Parameters Name="DebugCWD"></Parameters>
  138 + <Parameters Name="Debug Symbols Search Path"></Parameters>
  139 + <Parameters Name="LoadAllSymbols">True</Parameters>
  140 + <Parameters Name="LoadUnspecifiedSymbols">False</Parameters>
  141 + </Parameters>
  142 + <Language>
  143 + <Language Name="ActiveLang"></Language>
  144 + <Language Name="ProjectLang">$00000000</Language>
  145 + <Language Name="RootDir"></Language>
  146 + </Language>
  147 + <VersionInfo>
  148 + <VersionInfo Name="IncludeVerInfo">False</VersionInfo>
  149 + <VersionInfo Name="AutoIncBuild">False</VersionInfo>
  150 + <VersionInfo Name="MajorVer">1</VersionInfo>
  151 + <VersionInfo Name="MinorVer">0</VersionInfo>
  152 + <VersionInfo Name="Release">0</VersionInfo>
  153 + <VersionInfo Name="Build">0</VersionInfo>
  154 + <VersionInfo Name="Debug">False</VersionInfo>
  155 + <VersionInfo Name="PreRelease">False</VersionInfo>
  156 + <VersionInfo Name="Special">False</VersionInfo>
  157 + <VersionInfo Name="Private">False</VersionInfo>
  158 + <VersionInfo Name="DLL">False</VersionInfo>
  159 + <VersionInfo Name="Locale">1044</VersionInfo>
  160 + <VersionInfo Name="CodePage">1252</VersionInfo>
  161 + </VersionInfo>
  162 + <VersionInfoKeys>
  163 + <VersionInfoKeys Name="CompanyName"></VersionInfoKeys>
  164 + <VersionInfoKeys Name="FileDescription"></VersionInfoKeys>
  165 + <VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys>
  166 + <VersionInfoKeys Name="InternalName"></VersionInfoKeys>
  167 + <VersionInfoKeys Name="LegalCopyright"></VersionInfoKeys>
  168 + <VersionInfoKeys Name="LegalTrademarks"></VersionInfoKeys>
  169 + <VersionInfoKeys Name="OriginalFilename"></VersionInfoKeys>
  170 + <VersionInfoKeys Name="ProductName"></VersionInfoKeys>
  171 + <VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys>
  172 + <VersionInfoKeys Name="Comments"></VersionInfoKeys>
  173 + </VersionInfoKeys> <Excluded_Packages>
  174 + <Excluded_Packages Name="C:\Programfiler\Fellesfiler\RemObjects Software\Everwood\Bin\RemObjects_Everwood_D10.bpl">RemObjects Everwood for Delphi</Excluded_Packages>
  175 + <Excluded_Packages Name="C:\Programfiler\RemObjects Software\RemObjects SDK for Delphi\Dcu\D10\RemObjects_Core_D10.bpl">RemObjects SDK - Core Library</Excluded_Packages>
  176 + <Excluded_Packages Name="C:\Programfiler\RemObjects Software\RemObjects SDK for Delphi\Dcu\D10\RemObjects_WebBroker_D10.bpl">RemObjects SDK - WebBroker Library</Excluded_Packages>
  177 + <Excluded_Packages Name="C:\Programfiler\RemObjects Software\RemObjects SDK for Delphi\Dcu\D10\RemObjects_RODX_D10.bpl">RemObjects SDK - RODXSock Library</Excluded_Packages>
  178 + <Excluded_Packages Name="C:\Programfiler\RemObjects Software\RemObjects SDK for Delphi\Dcu\D10\RemObjects_BPDX_D10.bpl">RemObjects SDK - BPDX Library</Excluded_Packages>
  179 + <Excluded_Packages Name="C:\Programfiler\RemObjects Software\RemObjects SDK for Delphi\Dcu\D10\RemObjects_DataSnap_D10.bpl">RemObjects SDK - DataSnap Integration Pack</Excluded_Packages>
  180 + <Excluded_Packages Name="C:\Programfiler\RemObjects Software\Pascal Script\Dcu\D10\PascalScript_Core_D10.bpl">RemObjects Pascal Script - Core Package</Excluded_Packages>
  181 + <Excluded_Packages Name="C:\Programfiler\RemObjects Software\Pascal Script\Dcu\D10\PascalScript_RO_D10.bpl">RemObjects Pascal Script - RemObjects SDK 3.0 Integration</Excluded_Packages>
  182 + <Excluded_Packages Name="C:\Programfiler\RemObjects Software\RemObjects SDK for Delphi\Dcu\D10\RemObjects_Indy_D10.bpl">RemObjects SDK - Indy Library</Excluded_Packages>
  183 + <Excluded_Packages Name="C:\Programfiler\RemObjects Software\RemObjects SDK for Delphi\Dcu\D10\RemObjects_IDE_D10.bpl">RemObjects SDK - IDE Integration for Win32</Excluded_Packages>
  184 + <Excluded_Packages Name="C:\Programfiler\RemObjects Software\Data Abstract for Delphi\Dcu\D10\DataAbstract_Core_D10.bpl">RemObjects Data Abstract - Core Library</Excluded_Packages>
  185 + <Excluded_Packages Name="C:\Programfiler\RemObjects Software\Data Abstract for Delphi\Dcu\D10\DataAbstract_IDE_D10.bpl">RemObjects Data Abstract - IDE Package</Excluded_Packages>
  186 + <Excluded_Packages Name="C:\Programfiler\RemObjects Software\Data Abstract for Delphi\Dcu\D10\DataAbstract_ADODriver_D10.bpl">RemObjects Data Abstract - ADOExpress/dbGo Driver</Excluded_Packages>
  187 + <Excluded_Packages Name="C:\Programfiler\RemObjects Software\Data Abstract for Delphi\Dcu\D10\DataAbstract_IBXDriver_D10.bpl">RemObjects Data Abstract - InterBase Express Driver</Excluded_Packages>
  188 + <Excluded_Packages Name="C:\Programfiler\RemObjects Software\Data Abstract for Delphi\Dcu\D10\DataAbstract_DBXDriver_D10.bpl">RemObjects Data Abstract - dbExpress Driver</Excluded_Packages>
  189 + <Excluded_Packages Name="C:\Programfiler\RemObjects Software\Data Abstract for Delphi\Dcu\D10\DataAbstract_Scripting_D10.bpl">RemObjects Data Abstract - Scripting Integration Library</Excluded_Packages>
  190 + </Excluded_Packages>
  191 + </Delphi.Personality>
  192 + <StarTeamAssociation></StarTeamAssociation>
  193 + <StarTeamNonRelativeFiles></StarTeamNonRelativeFiles>
  194 +</BorlandProject>
... ...
ktwsapi/delphi/examples/KTWSAPIExamples.dpr 0 → 100644
  1 +{
  2 + Copyright (c) 2007, The Jam Warehouse Software (Pty) Ltd.
  3 +
  4 + All rights reserved.
  5 +
  6 + Redistribution and use in source and binary forms, with or without
  7 + modification, are permitted provided that the following conditions are met:
  8 +
  9 + i) Redistributions of source code must retain the above copyright notice,
  10 + this list of conditions and the following disclaimer.
  11 + ii) Redistributions in binary form must reproduce the above copyright
  12 + notice, this list of conditions and the following disclaimer in the
  13 + documentation and/or other materials provided with the distribution.
  14 + iii) Neither the name of the The Jam Warehouse Software (Pty) Ltd nor the
  15 + names of its contributors may be used to endorse or promote products
  16 + derived from this software without specific prior written permission.
  17 +
  18 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19 + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20 + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21 + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  22 + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  23 + EXEMPLARY, OR CONSEQUENTIAL DAMAGES ( INCLUDING, BUT NOT LIMITED TO,
  24 + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  25 + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  26 + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ( INCLUDING
  27 + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28 + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29 +}
  30 +
  31 +{*
  32 + This is a Delphi port of the php api for KnowledgeTree WebService.
  33 +
  34 + @Author Bjarte Kalstveit Vebjørnsen <bjarte@macaos.com>
  35 + @Version 1.0 BKV 24.09.2007 Initial revision
  36 +*}
  37 +
  38 +
  39 +program KTWSAPIExamples;
  40 +
  41 +uses
  42 + Forms,
  43 + uFolderContentExample in 'uFolderContentExample.pas' {FolderContentExample},
  44 + uwebservice in '..\uwebservice.pas',
  45 + uktwsapi in '..\uktwsapi.pas',
  46 + uPHPserialize in '..\uPHPserialize.pas';
  47 +
  48 +{$R *.res}
  49 +
  50 +begin
  51 + Application.Initialize;
  52 + Application.CreateForm(TFolderContentExample, FolderContentExample);
  53 + Application.Run;
  54 +end.
  55 +
... ...
ktwsapi/delphi/examples/KTWSAPIExamples.res 0 → 100644
No preview for this file type
ktwsapi/delphi/examples/uFolderContentExample.dfm 0 → 100644
  1 +object FolderContentExample: TFolderContentExample
  2 + Left = 0
  3 + Top = 0
  4 + Caption = 'FolderContentExample'
  5 + ClientHeight = 538
  6 + ClientWidth = 219
  7 + Color = clBtnFace
  8 + Font.Charset = DEFAULT_CHARSET
  9 + Font.Color = clWindowText
  10 + Font.Height = -11
  11 + Font.Name = 'Tahoma'
  12 + Font.Style = []
  13 + OldCreateOrder = False
  14 + PixelsPerInch = 96
  15 + TextHeight = 13
  16 + object tvFolderList: TTreeView
  17 + AlignWithMargins = True
  18 + Left = 3
  19 + Top = 34
  20 + Width = 213
  21 + Height = 501
  22 + Align = alClient
  23 + Images = ImageList4
  24 + Indent = 19
  25 + TabOrder = 0
  26 + OnCollapsed = tvFolderListCollapsed
  27 + OnExpanded = tvFolderListExpanded
  28 + end
  29 + object Button1: TButton
  30 + AlignWithMargins = True
  31 + Left = 3
  32 + Top = 3
  33 + Width = 213
  34 + Height = 25
  35 + Align = alTop
  36 + Caption = 'Populate folders'
  37 + TabOrder = 1
  38 + OnClick = Button1Click
  39 + end
  40 + object ImageList4: TImageList
  41 + Left = 8
  42 + Top = 496
  43 + Bitmap = {
  44 + 494C010102000400040010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
  45 + 0000000000003600000028000000400000001000000001002000000000000010
  46 + 00000000000000000000000000000000000000000000078DBE00078DBE00078D
  47 + BE00078DBE00078DBE00078DBE00078DBE00078DBE00078DBE00078DBE00078D
  48 + BE00078DBE00078DBE00000000000000000000000000078DBE00078DBE00078D
  49 + BE00078DBE00078DBE00078DBE00078DBE00078DBE00078DBE00078DBE00078D
  50 + BE00078DBE000000000000000000000000000000000000000000000000000000
  51 + 0000000000000000000000000000000000000000000000000000000000000000
  52 + 0000000000000000000000000000000000000000000000000000000000000000
  53 + 0000000000000000000000000000000000000000000000000000000000000000
  54 + 000000000000000000000000000000000000078DBE0063CBF800078DBE00A3E1
  55 + FB0066CDF90065CDF80065CDF90065CDF90065CDF80065CDF90065CDF80066CD
  56 + F8003AADD800ACE7F500078DBE0000000000078DBE0025A1D10071C6E80084D7
  57 + FA0066CDF90065CDF90065CDF90065CDF90065CDF80065CDF90065CDF80066CE
  58 + F9003AADD8001999C90000000000000000000000000000000000000000000000
  59 + 0000000000000000000000000000000000000000000000000000000000000000
  60 + 0000000000000000000000000000000000000000000000000000000000000000
  61 + 0000000000000000000000000000000000000000000000000000000000000000
  62 + 000000000000000000000000000000000000078DBE006AD1F900078DBE00A8E5
  63 + FC006FD4FA006FD4F9006ED4FA006FD4F9006FD4FA006FD4FA006FD4FA006ED4
  64 + F9003EB1D900B1EAF500078DBE0000000000078DBE004CBCE70039A8D100A0E2
  65 + FB006FD4FA006FD4F9006ED4FA006FD4F9006FD4FA006FD4FA006FD4FA006ED4
  66 + F9003EB1D900C9F0F300078DBE00000000000000000000000000000000000000
  67 + 0000000000000000000000000000000000000000000000000000000000000000
  68 + 0000000000000000000000000000000000000000000000000000000000000000
  69 + 0000000000000000000000000000000000000000000000000000000000000000
  70 + 000000000000000000000000000000000000078DBE0072D6FA00078DBE00AEEA
  71 + FC0079DCFB0079DCFB0079DCFB0079DCFB0079DCFB007ADCFB0079DCFA0079DC
  72 + FA0044B5D900B6EEF600078DBE0000000000078DBE0072D6FA00078DBE00AEE9
  73 + FC0079DCFB0079DCFB0079DCFB0079DCFB0079DCFB007ADCFB0079DCFA0079DC
  74 + FA0044B5D900C9F0F300078DBE00000000000000000000000000000000000000
  75 + 0000000000000000000000000000000000000000000000000000000000000000
  76 + 0000000000000000000000000000000000000000000000000000000000000000
  77 + 0000000000000000000000000000000000000000000000000000000000000000
  78 + 000000000000000000000000000000000000078DBE0079DDFB00078DBE00B5EE
  79 + FD0083E4FB0084E4FB0083E4FC0083E4FC0084E4FC0083E4FC0083E4FB0084E5
  80 + FC0048B9DA00BBF2F600078DBE0000000000078DBE0079DDFB001899C7009ADF
  81 + F30092E7FC0084E4FB0083E4FC0083E4FC0084E4FC0083E4FC0083E4FB0084E5
  82 + FC0048B9DA00C9F0F3001496C400000000000000000000000000000000000000
  83 + 0000000000000000000000000000000000000000000000000000000000000000
  84 + 0000000000000000000000000000000000000000000000000000000000000000
  85 + 0000000000000000000000000000000000000000000000000000000000000000
  86 + 000000000000000000000000000000000000078DBE0082E3FC00078DBE00BAF3
  87 + FD008DEBFC008DEBFC008DEBFC008DEBFD008DEBFD008DEBFC008DEBFD008DEB
  88 + FC004CBBDA00BEF4F700078DBE0000000000078DBE0082E3FC0043B7DC0065C2
  89 + E000ABF0FC008DEBFC008DEBFC008DEBFD008DEBFD008DEBFC008DEBFD008DEB
  90 + FC004CBBDA00C9F0F300C9F0F300078DBE000000000000000000000000000000
  91 + 0000000000000000000000000000000000000000000000000000000000000000
  92 + 0000000000000000000000000000000000000000000000000000000000000000
  93 + 0000000000000000000000000000000000000000000000000000000000000000
  94 + 000000000000000000000000000000000000078DBE008AEAFC00078DBE00FFFF
  95 + FF00C9F7FE00C8F7FE00C9F7FE00C9F7FE00C9F7FE00C8F7FE00C9F7FE00C8F7
  96 + FE009BD5E700DEF9FB00078DBE0000000000078DBE008AEAFC0077DCF300219C
  97 + C700FEFFFF00C8F7FD00C9F7FD00C9F7FD00C9F7FE00C8F7FE00C9F7FD00C8F7
  98 + FE009BD5E600EAFEFE00D2F3F800078DBE000000000000000000000000000000
  99 + 0000000000000000000000000000000000000000000000000000000000000000
  100 + 0000000000000000000000000000000000000000000000000000000000000000
  101 + 0000000000000000000000000000000000000000000000000000000000000000
  102 + 000000000000000000000000000000000000078DBE0093F0FE00078DBE00078D
  103 + BE00078DBE00078DBE00078DBE00078DBE00078DBE00078DBE00078DBE00078D
  104 + BE00078DBE00078DBE00078DBE0000000000078DBE0093F0FE0093F0FD001697
  105 + C500078DBE00078DBE00078DBE00078DBE00078DBE00078DBE00078DBE00078D
  106 + BE00078DBE00078DBE00078DBE00078DBE000000000000000000000000000000
  107 + 0000000000000000000000000000000000000000000000000000000000000000
  108 + 0000000000000000000000000000000000000000000000000000000000000000
  109 + 0000000000000000000000000000000000000000000000000000000000000000
  110 + 000000000000000000000000000000000000078DBE009BF5FE009AF6FE009AF6
  111 + FE009BF5FD009BF6FE009AF6FE009BF5FE009AF6FD009BF5FE009AF6FE009AF6
  112 + FE000989BA00000000000000000000000000078DBE009BF5FE009AF6FE009AF6
  113 + FE009BF5FD009BF6FE009AF6FE009BF5FE009AF6FD009BF5FE009AF6FE009AF6
  114 + FE000989BA000000000000000000000000000000000000000000000000000000
  115 + 0000000000000000000000000000000000000000000000000000000000000000
  116 + 0000000000000000000000000000000000000000000000000000000000000000
  117 + 0000000000000000000000000000000000000000000000000000000000000000
  118 + 000000000000000000000000000000000000078DBE00FEFEFE00A0FBFF00A0FB
  119 + FE00A0FBFE00A1FAFE00A1FBFE00A0FAFE00A1FBFE00A1FBFF00A0FBFF00A1FB
  120 + FF000989BA00000000000000000000000000078DBE00FEFEFE00A0FBFF00A0FB
  121 + FE00A0FBFE00A1FAFE00A1FBFE00A0FAFE00A1FBFE00A1FBFF00A0FBFF00A1FB
  122 + FF000989BA000000000000000000000000000000000000000000000000000000
  123 + 0000000000000000000000000000000000000000000000000000000000000000
  124 + 0000000000000000000000000000000000000000000000000000000000000000
  125 + 0000000000000000000000000000000000000000000000000000000000000000
  126 + 00000000000000000000000000000000000000000000078DBE00FEFEFE00A5FE
  127 + FF00A5FEFF00A5FEFF00078DBE00078DBE00078DBE00078DBE00078DBE00078D
  128 + BE000000000000000000000000000000000000000000078DBE00FEFEFE00A5FE
  129 + FF00A5FEFF00A5FEFF00078DBE00078DBE00078DBE00078DBE00078DBE00078D
  130 + BE00000000000000000000000000000000000000000000000000000000000000
  131 + 0000000000000000000000000000000000000000000000000000000000000000
  132 + 0000000000000000000000000000000000000000000000000000000000000000
  133 + 0000000000000000000000000000000000000000000000000000000000000000
  134 + 0000000000000000000000000000000000000000000000000000078DBE00078D
  135 + BE00078DBE00078DBE0000000000000000000000000000000000000000000000
  136 + 0000000000000000000000000000000000000000000000000000078DBE00078D
  137 + BE00078DBE00078DBE0000000000000000000000000000000000000000000000
  138 + 0000000000000000000000000000000000000000000000000000000000000000
  139 + 0000000000000000000000000000000000000000000000000000000000000000
  140 + 0000000000000000000000000000000000000000000000000000000000000000
  141 + 0000000000000000000000000000000000000000000000000000000000000000
  142 + 0000000000000000000000000000000000000000000000000000000000000000
  143 + 0000000000000000000000000000000000000000000000000000000000000000
  144 + 0000000000000000000000000000000000000000000000000000000000000000
  145 + 0000000000000000000000000000000000000000000000000000000000000000
  146 + 0000000000000000000000000000000000000000000000000000000000000000
  147 + 0000000000000000000000000000000000000000000000000000000000000000
  148 + 0000000000000000000000000000000000000000000000000000000000000000
  149 + 0000000000000000000000000000000000000000000000000000000000000000
  150 + 0000000000000000000000000000000000000000000000000000000000000000
  151 + 0000000000000000000000000000000000000000000000000000000000000000
  152 + 0000000000000000000000000000000000000000000000000000000000000000
  153 + 0000000000000000000000000000000000000000000000000000000000000000
  154 + 0000000000000000000000000000000000000000000000000000000000000000
  155 + 0000000000000000000000000000000000000000000000000000000000000000
  156 + 0000000000000000000000000000000000000000000000000000000000000000
  157 + 0000000000000000000000000000000000000000000000000000000000000000
  158 + 0000000000000000000000000000000000000000000000000000000000000000
  159 + 0000000000000000000000000000000000000000000000000000000000000000
  160 + 0000000000000000000000000000000000000000000000000000000000000000
  161 + 0000000000000000000000000000000000000000000000000000000000000000
  162 + 0000000000000000000000000000000000000000000000000000000000000000
  163 + 0000000000000000000000000000000000000000000000000000000000000000
  164 + 0000000000000000000000000000000000000000000000000000000000000000
  165 + 0000000000000000000000000000000000000000000000000000000000000000
  166 + 0000000000000000000000000000000000000000000000000000000000000000
  167 + 0000000000000000000000000000000000000000000000000000000000000000
  168 + 0000000000000000000000000000000000000000000000000000000000000000
  169 + 0000000000000000000000000000000000000000000000000000000000000000
  170 + 0000000000000000000000000000000000000000000000000000000000000000
  171 + 0000000000000000000000000000000000000000000000000000000000000000
  172 + 0000000000000000000000000000000000000000000000000000000000000000
  173 + 0000000000000000000000000000000000000000000000000000000000000000
  174 + 000000000000000000000000000000000000424D3E000000000000003E000000
  175 + 2800000040000000100000000100010000000000800000000000000000000000
  176 + 000000000000000000000000FFFFFF0080038007000000000001000300000000
  177 + 0001000100000000000100010000000000010001000000000001000000000000
  178 + 0001000000000000000100000000000000070007000000000007000700000000
  179 + 800F800F00000000C3FFC3FF00000000FFFFFFFF00000000FFFFFFFF00000000
  180 + FFFFFFFF00000000FFFFFFFF0000000000000000000000000000000000000000
  181 + 000000000000}
  182 + end
  183 +end
... ...
ktwsapi/delphi/examples/uFolderContentExample.pas 0 → 100644
  1 +unit uFolderContentExample;
  2 +
  3 +interface
  4 +
  5 +uses
  6 + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  7 + Dialogs, uKtwsapi, uWebService, ImgList, ComCtrls, StdCtrls;
  8 +
  9 +type
  10 + TFolderContentExample = class(TForm)
  11 + tvFolderList: TTreeView;
  12 + ImageList4: TImageList;
  13 + Button1: TButton;
  14 + procedure Button1Click(Sender: TObject);
  15 + procedure tvFolderListCollapsed(Sender: TObject; Node: TTreeNode);
  16 + procedure tvFolderListExpanded(Sender: TObject; Node: TTreeNode);
  17 + private
  18 + { Private declarations }
  19 + FIsPopulating: Boolean;
  20 + procedure PopulateTreeView(items: kt_folder_items;
  21 + parent: TTreeNode; tv: TTreeView);
  22 + public
  23 + { Public declarations }
  24 + end;
  25 +
  26 +var
  27 + FolderContentExample: TFolderContentExample;
  28 + UserName, Password: String;
  29 +
  30 +implementation
  31 +
  32 +{$R *.dfm}
  33 +
  34 +procedure TFolderContentExample.Button1Click(Sender: TObject);
  35 +var
  36 + ktapi: TKTWSAPI;
  37 + folder: TKTWSAPI_Folder;
  38 + contents: kt_folder_contents;
  39 +begin
  40 + if FIsPopulating then Exit;
  41 +
  42 + Screen.Cursor := crHourglass;
  43 +
  44 + FIsPopulating := True;
  45 + ktapi := TKTWSAPI.Create;
  46 + try
  47 + ktapi.SetDownloadPath(ExtractFileDir(Application.ExeName));
  48 + ktapi.StartSession(UserName,Password);
  49 +
  50 + folder:= ktapi.GetRootFolder;
  51 + try
  52 + contents := folder.GetListing(10);
  53 + try
  54 + PopulateTreeView(contents.items, nil, tvFolderList);
  55 + finally
  56 + contents.Free;
  57 + end;
  58 + finally
  59 + folder.Free;
  60 + end;
  61 +
  62 + ktapi.Logout;
  63 + finally
  64 + ktapi.Free;
  65 + Screen.Cursor := crDefault;
  66 + FIsPopulating := False;
  67 + end;
  68 +end;
  69 +
  70 +procedure TFolderContentExample.PopulateTreeView(items: kt_folder_items; parent: TTreeNode;
  71 + tv: TTreeView);
  72 +var
  73 + I: Integer;
  74 + node: TTreeNode;
  75 + it: kt_folder_item;
  76 +begin
  77 + for I := 0 to Length(items) - 1 do
  78 + begin
  79 + it := items[i];
  80 + if it.item_type <> 'F' then Continue;
  81 + node := tv.Items.AddChild(parent, it.title);
  82 + node.ImageIndex := 0;
  83 + node.Data := it;
  84 + if (Length(it.items) > 0) then
  85 + PopulateTreeView(it.items, node, tv);
  86 + end;
  87 +end;
  88 +
  89 +procedure TFolderContentExample.tvFolderListCollapsed(Sender: TObject;
  90 + Node: TTreeNode);
  91 +begin
  92 + Node.ImageIndex := 0;
  93 +end;
  94 +
  95 +procedure TFolderContentExample.tvFolderListExpanded(Sender: TObject;
  96 + Node: TTreeNode);
  97 +begin
  98 + Node.ImageIndex := 1;
  99 +end;
  100 +
  101 +initialization
  102 + UserName := 'xxxx';
  103 + Password := 'xxxx';
  104 + uktwsapi.KTWebServerUrl := 'http://ktdms.trunk';
  105 + uktwsapi.KTWebServiceUrl := uktwsapi.KTWebServerUrl+'/ktwebservice/webservice.php?wsdl';
  106 + uktwsapi.KTUploadUrl := uktwsapi.KTWebServerUrl+'/ktwebservice/upload.php';
  107 +
  108 +end.
... ...
ktwsapi/delphi/uPHPserialize.pas 0 → 100644
  1 +{
  2 + Copyright (c) 2007, The Jam Warehouse Software (Pty) Ltd.
  3 +
  4 + All rights reserved.
  5 +
  6 + Redistribution and use in source and binary forms, with or without
  7 + modification, are permitted provided that the following conditions are met:
  8 +
  9 + i) Redistributions of source code must retain the above copyright notice,
  10 + this list of conditions and the following disclaimer.
  11 + ii) Redistributions in binary form must reproduce the above copyright
  12 + notice, this list of conditions and the following disclaimer in the
  13 + documentation and/or other materials provided with the distribution.
  14 + iii) Neither the name of the The Jam Warehouse Software (Pty) Ltd nor the
  15 + names of its contributors may be used to endorse or promote products
  16 + derived from this software without specific prior written permission.
  17 +
  18 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19 + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20 + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21 + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  22 + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  23 + EXEMPLARY, OR CONSEQUENTIAL DAMAGES ( INCLUDING, BUT NOT LIMITED TO,
  24 + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  25 + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  26 + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ( INCLUDING
  27 + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28 + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29 +}
  30 +
  31 +{*
  32 + A helper unit to unserialize a php serialized string
  33 +
  34 + Inspired by the various implementaions presented here
  35 + http://www.phpguru.org/static/PHP_Unserialize.html
  36 +
  37 + @Author Bjarte Kalstveit Vebjørnsen <bjarte@macaos.com>
  38 + @Version 1.0 BKV 24.09.2007 Initial revision
  39 + @Todo A complementary serializing function would be nice
  40 +*}
  41 +
  42 +unit uPHPSerialize;
  43 +
  44 +interface
  45 +
  46 +uses
  47 + Classes, SysUtils, Variants, ComCtrls;
  48 +
  49 +type
  50 + TPHPValue = class;
  51 + TPHPArray = class;
  52 + TPHPSerialize = class;
  53 +
  54 + /// a single hash element
  55 + TPHPHashElement = record
  56 + Key: TPHPValue; /// The Key part of the element
  57 + Value: TPHPValue; /// The Value part of the element
  58 + end;
  59 +
  60 + /// an array of hash elements
  61 + TPHPHashedElementArray = array of TPHPHashElement;
  62 +
  63 + /// Tries to replicate a php array by accessing values through strings
  64 + /// @Todo: Add support for numeric keys
  65 + TPHPArray = class
  66 + private
  67 + FElements: TPHPHashedElementArray; /// array of hash elements
  68 + function GetValue(Key: string): TPHPValue; overload;
  69 + function GetValue(Key: TPHPValue): TPHPValue; overload;
  70 + procedure SetValue(Key: TPHPValue; VValue: TPHPValue); overload;
  71 + function GetCount: Integer;
  72 + function Getempty: Boolean;
  73 + public
  74 + property Value[Key: string]: TPHPValue read GetValue; default;
  75 + property Value[Key: TPHPValue]: TPHPValue read GetValue write SetValue; default;
  76 + property Count: Integer read GetCount;
  77 + property Empty: Boolean read Getempty;
  78 + procedure Clear;
  79 + constructor Create;
  80 + destructor Destroy; override;
  81 + end;
  82 +
  83 + /// Tries to represent a PHP value of any type
  84 + TPHPValue = class
  85 + private
  86 + FObj: TObject; /// Holds value if it's an object or array
  87 + FValue: String; /// Holds value if it's something else
  88 + procedure Clear;
  89 + public
  90 + constructor Create(Value: TObject); overload;
  91 + constructor Create(Value: String); overload;
  92 + destructor Destroy; override;
  93 + function AsString: String;
  94 + function AsDouble: Double;
  95 + function AsInteger: Integer;
  96 + function AsObject: TObject;
  97 + function AsArray: TPHPArray;
  98 + function AsBoolean: Boolean;
  99 + end;
  100 +
  101 + /// Class for unserializing a php serialized string
  102 + TPHPSerialize = class
  103 + private
  104 + function GetLength(Data: String): Integer;
  105 + function GetIntLength(Value: Integer): Integer;
  106 + public
  107 + class function Unserialize(Data: String): TPHPValue;
  108 + function _Unserialize(var Data: String): TPHPValue;
  109 + end;
  110 +
  111 +implementation
  112 +
  113 +{ TPHPSerialize }
  114 +
  115 +{*
  116 + Finds the length of they to the type
  117 +
  118 + @param string Data
  119 + @return integer
  120 +*}
  121 +function TPHPSerialize.GetLength(Data: String): Integer;
  122 +begin
  123 + Data := Copy(Data, 3, Length(Data));
  124 +
  125 + Result := StrToIntDef(Copy(Data, 0, Pos(':', Data)-1), 0);
  126 +end;
  127 +
  128 +{*
  129 + Finds the lenght of the character-space the value occupies
  130 +
  131 + @param integer Value
  132 + @return Integer
  133 +*}
  134 +function TPHPSerialize.GetIntLength(Value: Integer): Integer;
  135 +begin
  136 + Result := Length(IntToStr(Value));
  137 +end;
  138 +
  139 +{*
  140 + Helper function to use this class statically
  141 +
  142 + @param integer Value
  143 + @return Integer
  144 +*}
  145 +class function TPHPSerialize.Unserialize(Data: String): TPHPValue;
  146 +var
  147 + obj: TPHPSerialize;
  148 +begin
  149 + obj := TPHPSerialize.Create;
  150 + try
  151 + Result := obj._Unserialize(Data);
  152 + finally
  153 + obj.Free;
  154 + end;
  155 +end;
  156 +
  157 +{*
  158 + Recursing function for unserializing a string and creating a php value from it
  159 +
  160 + @see TPHPValue
  161 + @param Data String
  162 + @return TPHPValue
  163 +*}
  164 +function TPHPSerialize._Unserialize(var Data: String): TPHPValue;
  165 +var
  166 + I, Len: Integer;
  167 + Num: Double;
  168 + C: String;
  169 + Arr: TPHPArray;
  170 + Key, Value: TPHPValue;
  171 +begin
  172 + C := Copy(Data,0,1);
  173 +
  174 + if (C = 'a') then
  175 + begin
  176 + Len := GetLength(Data);
  177 + Data := Copy(Data, GetIntLength(Len) + 5, Length(Data) );
  178 +
  179 + Arr := TPHPArray.Create;
  180 + for I := 0 to Len-1 do
  181 + begin
  182 + Key := _Unserialize(Data);
  183 + Value := _Unserialize(Data);
  184 +
  185 + Arr[Key] := Value;
  186 + end;
  187 +
  188 + Data := Copy(Data, Length(Data));
  189 + Result := TPHPValue.Create(Arr);
  190 +
  191 + end else if (C = 's') then
  192 + begin
  193 + Len := GetLength(Data);
  194 + Result := TPHPValue.Create(Copy(Data, GetIntLength(Len) + 5, Len));
  195 + Data := Copy(Data, GetIntLength(Len) + 7 + Len, Length(Data));
  196 + end else if (C = 'i') or (C = 'd') then
  197 + begin
  198 + Num := StrToFloat(Copy(Data, 3, AnsiPos(';', Data)-3));
  199 + Result := TPHPValue.Create(FloatToStr(Num));
  200 + Data := Copy(Data, Length(FloatToStr(Num)) + 4, Length(Data));
  201 + end else if (C = 'b') then
  202 + begin
  203 + Result := TPHPValue.Create(BoolToStr(Copy(Data, 3, 1) = '1'));
  204 + Data := Copy(Data, 4, Length(Data));
  205 + end else if (C = 'O') or (C = 'r') or (C = 'C') or (C = 'R')
  206 + or (C = 'U') then
  207 + begin
  208 + raise Exception.Create('Unsupported PHP data type found!');
  209 + end else if (C = 'N') then
  210 + begin
  211 + Result := TPHPValue.Create(nil);
  212 + Data := Copy(Data, 2, Length(Data));
  213 + end else
  214 + begin
  215 + Result := TPHPValue.Create(nil);
  216 + Data := '';
  217 + end;
  218 +end;
  219 +
  220 +
  221 +{ TPHPValue }
  222 +
  223 +{*
  224 + Returns value as boolan
  225 +
  226 + @return boolean value
  227 +*}
  228 +function TPHPValue.AsBoolean: Boolean;
  229 +begin
  230 + Result := StrToBool(FValue);
  231 +end;
  232 +
  233 +{*
  234 + Returns value as double
  235 +
  236 + @return double value
  237 +*}
  238 +function TPHPValue.AsDouble: Double;
  239 +begin
  240 + Result := StrToFloat(FValue);
  241 +end;
  242 +
  243 +{*
  244 + Returns value as an associative-array
  245 +
  246 + @return associative-array
  247 +*}
  248 +function TPHPValue.AsArray: TPHPArray;
  249 +begin
  250 + Result := nil;
  251 + Assert(Assigned(FObj));
  252 +
  253 + if (FObj.ClassType = TPHPArray) then
  254 + Result := TPHPArray(FObj);
  255 +end;
  256 +
  257 +{*
  258 + Returns value as an integer
  259 +
  260 + @return integer value
  261 +*}
  262 +function TPHPValue.AsInteger: Integer;
  263 +begin
  264 + Result := StrToInt(FValue);
  265 +end;
  266 +
  267 +{*
  268 + Returns value as an object
  269 +
  270 + @return object value
  271 +*}
  272 +function TPHPValue.AsObject: TObject;
  273 +begin
  274 + Assert(Assigned(FObj));
  275 + Result := FObj;
  276 +end;
  277 +
  278 +{*
  279 + Returns value as a string
  280 +
  281 + @return string value
  282 +*}
  283 +function TPHPValue.AsString: String;
  284 +begin
  285 + Result := FValue;
  286 +end;
  287 +
  288 +{*
  289 + Constructor
  290 +
  291 + @param Value Value to store
  292 +*}
  293 +constructor TPHPValue.Create(Value: String);
  294 +begin
  295 + Clear;
  296 + FValue := Value;
  297 +end;
  298 +
  299 +{*
  300 + Constructor
  301 +
  302 + @param Value Value to store
  303 +*}
  304 +constructor TPHPValue.Create(Value: TObject);
  305 +begin
  306 + Clear;
  307 + FObj := Value;
  308 +end;
  309 +
  310 +{*
  311 + Clears current value
  312 +*}
  313 +procedure TPHPValue.Clear;
  314 +begin
  315 + FValue := '';
  316 + if Assigned(FObj) then FObj.Free;
  317 + FObj := nil;
  318 +end;
  319 +
  320 +{*
  321 + Destructor
  322 +*}
  323 +destructor TPHPValue.Destroy;
  324 +begin
  325 + Clear;
  326 + inherited;
  327 +end;
  328 +
  329 +{ TPHPArray }
  330 +
  331 +
  332 +{*
  333 + Clears whole array
  334 +*}
  335 +procedure TPHPArray.Clear;
  336 +var
  337 + i: Integer;
  338 +begin
  339 + for i := 0 to GetCount - 1 do
  340 + begin
  341 + FElements[i].Key.Free;
  342 + FElements[i].Key := nil;
  343 + FElements[i].Value.Free;
  344 + FElements[i].Value := nil;
  345 + end;
  346 + SetLength(FElements, 0);
  347 +end;
  348 +
  349 +{*
  350 + Constructor
  351 +*}
  352 +constructor TPHPArray.Create;
  353 +begin
  354 + inherited;
  355 + Clear;
  356 +end;
  357 +
  358 +{*
  359 + Destructor
  360 +*}
  361 +destructor TPHPArray.Destroy;
  362 +begin
  363 + Clear;
  364 + inherited;
  365 +end;
  366 +
  367 +{*
  368 + Returns the number of items in the array
  369 +
  370 + @return number of items
  371 +*}
  372 +function TPHPArray.GetCount: Integer;
  373 +begin
  374 + Result := Length(FElements);
  375 +end;
  376 +
  377 +{*
  378 + Checks if the array is empty
  379 +
  380 + @return true
  381 +*}
  382 +function TPHPArray.Getempty: Boolean;
  383 +begin
  384 + Result := Length(FElements) = 0;
  385 +end;
  386 +
  387 +{*
  388 + Fetch a phpvalue from the array
  389 +
  390 + @param Key Handle to phpvalue
  391 + @return handle to phpvalue
  392 +*}
  393 +function TPHPArray.GetValue(Key: TPHPValue): TPHPValue;
  394 +begin
  395 + Result := GetValue(Key.FValue);
  396 +end;
  397 +
  398 +{*
  399 + Fetch a phpvalue from the array
  400 +
  401 + @param Key Index to element
  402 + @return handle to phpvalue
  403 +*}
  404 +function TPHPArray.GetValue(Key: string): TPHPValue;
  405 +var
  406 + i: Integer;
  407 + r: Boolean;
  408 +begin
  409 + Result := nil;
  410 + i := 0;
  411 + r := False;
  412 + while (i < Length(FElements)) and (not r) do
  413 + begin
  414 + if AnsiUpperCase(FElements[i].key.AsString) = AnsiUpperCase(Key) then
  415 + begin
  416 + Result := FElements[i].Value;
  417 + r := True;
  418 + end;
  419 + i := i + 1;
  420 + end;
  421 +end;
  422 +
  423 +{*
  424 + Insert a phpvalue into the array
  425 +
  426 + @param Key Index to element
  427 + @return handle to phpvalue
  428 +*}
  429 +procedure TPHPArray.SetValue(Key, VValue: TPHPValue);
  430 +var
  431 + i, j: Integer;
  432 + r: Boolean;
  433 + E: TPHPHashedElementArray;
  434 +begin
  435 + if VValue <> nil then
  436 + begin
  437 + i := 0;
  438 + r := False;
  439 + while (i < Length(FElements)) and not r do
  440 + begin
  441 + if AnsiUpperCase(FElements[i].key.AsString) = AnsiUpperCase(Key.AsString) then
  442 + begin
  443 + FElements[i].Value := VValue;
  444 + r := True;
  445 + end;
  446 + i := i + 1;
  447 + end;
  448 + if not r then
  449 + begin
  450 + SetLength(FElements, Length(FElements) + 1);
  451 + FElements[Length(FElements) - 1].Key := Key;
  452 + FElements[Length(FElements) - 1].Value := Vvalue;
  453 + end;
  454 + end;
  455 +
  456 + SetLength(E, Length(FElements));
  457 + for i := 0 to Length(FElements) - 1 do E[i] := FElements[i];
  458 + SetLength(FElements, 0);
  459 + for i := 0 to Length(E) - 1 do if (E[i].Key.AsString <> '')
  460 + and (E[i].Value <> nil) then
  461 + begin
  462 + j := Length(FElements);
  463 + setlength(FElements, j + 1);
  464 + FElements[j] := E[i];
  465 + end;
  466 +end;
  467 +
  468 +end.
  469 +
... ...
ktwsapi/delphi/uktwsapi.pas 0 → 100644
  1 +{
  2 + Copyright (c) 2007, The Jam Warehouse Software (Pty) Ltd.
  3 +
  4 + All rights reserved.
  5 +
  6 + Redistribution and use in source and binary forms, with or without
  7 + modification, are permitted provided that the following conditions are met:
  8 +
  9 + i) Redistributions of source code must retain the above copyright notice,
  10 + this list of conditions and the following disclaimer.
  11 + ii) Redistributions in binary form must reproduce the above copyright
  12 + notice, this list of conditions and the following disclaimer in the
  13 + documentation and/or other materials provided with the distribution.
  14 + iii) Neither the name of the The Jam Warehouse Software (Pty) Ltd nor the
  15 + names of its contributors may be used to endorse or promote products
  16 + derived from this software without specific prior written permission.
  17 +
  18 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19 + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20 + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21 + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  22 + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  23 + EXEMPLARY, OR CONSEQUENTIAL DAMAGES ( INCLUDING, BUT NOT LIMITED TO,
  24 + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  25 + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  26 + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ( INCLUDING
  27 + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28 + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29 +}
  30 +
  31 +{*
  32 + This is a Delphi port of the php api for KnowledgeTree WebService.
  33 +
  34 + @Author Bjarte Kalstveit Vebjørnsen <bjarte@macaos.com>
  35 + @Version 1.0 BKV 24.09.2007 Initial revision
  36 +*}
  37 +
  38 +unit uktwsapi;
  39 +
  40 +interface
  41 +
  42 +uses
  43 + Classes, SysUtils, SOAPHTTPClient, uwebservice;
  44 +
  45 +type
  46 +
  47 + /// Base exception class
  48 + EKTWSAPI_Exception = class(Exception);
  49 +
  50 + TKTWSAPI_FolderItem = class;
  51 + TKTWSAPI_Folder = class;
  52 + TKTWSAPI_Document = class;
  53 + TKTWSAPI = class;
  54 +
  55 + /// Base class for documents and folders
  56 + TKTWSAPI_FolderItem = class(TObject)
  57 + private
  58 + FKTAPI: TKTWSAPI; /// Handle to KTAPI object
  59 + FParentId: Integer; /// Id of parent folder
  60 +
  61 + function _GetFileSize(FileName: WideString): WideString;
  62 + function _UploadFile(FileName, Action: WideString; DocumentId: Integer = 0): WideString;
  63 + function _DownloadFile(Url, LocalPath, FileName: WideString): Boolean;
  64 + function _SaveBase64StringAsFile(Base64String, LocalPath, FileName: WideString): Boolean;
  65 + function _LoadFileAsBase64String(FileName: WideString): WideString;
  66 +
  67 + public
  68 + function GetParentFolder:TKTWSAPI_Folder;
  69 + end;
  70 +
  71 + /// Class representing a folder
  72 + TKTWSAPI_Folder = class(TKTWSAPI_FolderItem)
  73 + private
  74 + FFolderName, /// Name of folder
  75 + FFullPath: WideString; /// Full path to folder
  76 +
  77 + FFolderId: Integer; /// Id to folder
  78 + public
  79 + constructor Create(KTAPI:TKTWSAPI; FolderDetail: kt_folder_detail); overload;
  80 + class function Get(KTAPI: TKTWSAPI; FolderId:Integer): TKTWSAPI_Folder;
  81 + function GetParentFolderId: Integer;
  82 + function GetFolderName: WideString;
  83 + function GetFolderId: Integer;
  84 + function GetFolderByName(FolderName: WideString): TKTWSAPI_Folder;
  85 + function GetFullPath: WideString;
  86 + function GetListing(Depth: Integer=1; What: WideString = 'DF'): kt_folder_contents;
  87 + function GetDocumentByName(Title: WideString): TKTWSAPI_Document;
  88 + function GetDocumentByFileName(FileName: WideString): TKTWSAPI_Document;
  89 + function AddFolder(FolderName: WideString): TKTWSAPI_Folder;
  90 + function Delete(Reason: WideString): Boolean;
  91 + function Rename(NewName: WideString): Boolean;
  92 + function Move(TargetFolder:TKTWSAPI_Folder; Reason: WideString): Boolean;
  93 + function Copy(TargetFolder:TKTWSAPI_Folder; Reason: WideString): Boolean;
  94 + function AddDocument(FileName: WideString; Title: WideString = '';
  95 + DocumentType: WideString = ''): TKTWSAPI_Document;
  96 + function AddDocumentBase64(FileName: WideString; Title: WideString = '';
  97 + DocumentType: WideString = ''): TKTWSAPI_Document;
  98 + published
  99 + property FolderName: WideString read FFolderName write FFolderName;
  100 + property FullPath: WideString read FFullPath write FFullPath;
  101 + property FolderId: Integer read FFolderId write FFolderId;
  102 + end;
  103 +
  104 + /// Class representing a document
  105 + TKTWSAPI_Document = class(TKTWSAPI_FolderItem)
  106 + private
  107 +
  108 + FDocumentId: Integer; /// Id of document
  109 + FTitle, /// Title of document
  110 + FDocumentType, /// Type of document
  111 + FVersion, /// Document version
  112 + FFileName, /// Original filename
  113 + FCreatedDate, /// Date created
  114 + FCreatedBy, /// Name of user who created
  115 + FUpdatedDate, /// Date updated
  116 + FUpdatedBy, /// Name of user who updated
  117 + FWorkflow, /// Workflow
  118 + FWorkflowState, /// Workflow state
  119 + FCheckoutBy, /// Name of user who checked out
  120 + FFullPath: WideString; /// Full path to document
  121 + public
  122 + constructor Create(KTAPI: TKTWSAPI; DocumentDetail: kt_document_detail);
  123 +
  124 + class function Get(KTAPI: TKTWSAPI; DocumentId: Integer;
  125 + LoadInfo: Boolean = System.True): TKTWSAPI_Document;
  126 + function Checkin(FileName, Reason: WideString; MajorUpdate: Boolean): Boolean;
  127 + function Checkout(Reason: WideString; LocalPath: WideString = '';
  128 + DownloadFile: Boolean = True): Boolean;
  129 + function UndoCheckout(Reason: WideString): Boolean;
  130 + function Download(Version: WideString = ''; LocalPath: WideString = ''; FileName: WideString = ''): Boolean;
  131 + function Delete(Reason: WideString): Boolean;
  132 + function ChangeOwner(UserName, Reason: WideString): Boolean;
  133 + function Copy(Folder: TKTWSAPI_Folder; Reason: WideString;
  134 + NewTitle: WideString = ''; NewFileName: WideString = ''): Boolean;
  135 + function Move(Folder: TKTWSAPI_Folder; Reason: WideString;
  136 + NewTitle: WideString = ''; NewFileName: WideString = ''): Boolean;
  137 + function ChangeDocumentType(DocumentType: WideString): Boolean;
  138 + function RenameTitle(NewTitle: WideString): Boolean;
  139 + function RenameFilename(NewFilename: WideString): Boolean;
  140 + function StartWorkflow(WorkFlow: WideString): Boolean;
  141 + function DeleteWorkflow: Boolean;
  142 + function PeformWorkflowTransition(Transition, Reason: WideString): Boolean;
  143 + function GetMetadata:kt_metadata_response;
  144 + function UpdateMetadata(Metadata: kt_metadata_fieldsets): Boolean;
  145 + function GetTransactionHistory: kt_document_transaction_history_response;
  146 + function GetVersionHistory: kt_document_version_history_response;
  147 + function GetLinks: kt_linked_document_response;
  148 + function Link(DocumentId: Integer; const LinkType: WideString): Boolean;
  149 + function Unlink(DocumentId: Integer): Boolean;
  150 + function CheckinBase64(FileName, Reason: WideString; MajorUpdate: Boolean): Boolean;
  151 + function CheckoutBase64(Reason: WideString; LocalPath: WideString = '';
  152 + DownloadFile: Boolean = True): Boolean;
  153 + function DownloadBase64(Version: WideString = ''; LocalPath: WideString = ''): Boolean;
  154 + function GetTypes: kt_document_types_response;
  155 + function GetLinkTypes: kt_document_types_response;
  156 +
  157 + property DocumentId: Integer read FDocumentId write FDocumentId;
  158 + property Title: WideString read FTitle write FTitle;
  159 + property DocumentType: WideString read FDocumentType write FDocumentType;
  160 + property Version: WideString read FVersion write FVersion;
  161 + property FileName: WideString read FFileName write FFileName;
  162 + property CreatedDate: WideString read FCreatedBy write FCreatedBy;
  163 + property CreatedBy: WideString read FCreatedBy write FCreatedBy;
  164 + property UpdatedDate: WideString read FUpdatedDate write FUpdatedDate;
  165 + property UpdatedBy: WideString read FUpdatedBy write FUpdatedBy;
  166 + property Workflow: WideString read FWorkflow write FWorkflow;
  167 + property WorkflowState: WideString read FWorkflowState write FWorkflowState;
  168 + property CheckoutBy: WideString read FCheckoutBy write FCheckoutBy;
  169 + property FullPath: WideString read FFullPath write FFullPath;
  170 + end;
  171 +
  172 + /// Api entry point
  173 + TKTWSAPI = class
  174 + private
  175 +
  176 + FSession, /// Current session id
  177 + FDownloadPath: WideString; /// Current download path
  178 +
  179 + FSoapClient:KnowledgeTreePort; /// Object implementing the
  180 + /// KnowledgeTreePort interface
  181 + public
  182 + constructor Create();
  183 + function GetDownloadPath: WideString;
  184 + function SetDownloadPath(DownloadPath:WideString): Boolean;
  185 + function StartAnonymousSession(Ip: WideString = ''): WideString;
  186 + function StartSession(Username, Password: WideString; Ip: WideString = ''): WideString;
  187 + function ActiveSession(Session: WideString; Ip: WideString = ''): WideString;
  188 + function Logout: Boolean;
  189 + function GetRootFolder: TKTWSAPI_Folder;
  190 + function GetFolderById(FolderId: Integer): TKTWSAPI_Folder;
  191 + function GetDocumentById(DocumentId: Integer): TKTWSAPI_Document;
  192 + published
  193 + property SoapClient: KnowledgeTreePort read FSoapClient write FSoapClient;
  194 + property Session: WideString read FSession write FSession;
  195 + end;
  196 +var
  197 + KTWebServerUrl: WideString; /// Your webserver url
  198 + KTUploadUrl: WideString; /// URL to the web-service upload.php
  199 + KTWebServiceUrl: WideString; /// URL to the web-service wsdl
  200 +
  201 +implementation
  202 +
  203 +uses
  204 + IdComponent, IdURI, IdHttp, IdMultipartFormData, IdGlobalProtocols,
  205 + uPHPSerialize, EncdDecd;
  206 +const
  207 + KTWSAPI_ERR_SESSION_IN_USE =
  208 + 'There is a session already active.'; /// Exception message when session is in use
  209 + KTWSAPI_ERR_SESSION_NOT_STARTED =
  210 + 'An active session has not been started.'; /// Exception message when session is not started
  211 +
  212 +
  213 +{ TKTWSAPI_FolderItem }
  214 +
  215 +{*
  216 + Finds the filesize of a file.
  217 +
  218 + @param FileName Path to the file
  219 + @return The size of the file as a string
  220 +*}
  221 +function TKTWSAPI_FolderItem._GetFileSize(FileName: WideString): WideString;
  222 +var
  223 + SearchRec: TSearchRec;
  224 + sgPath: string;
  225 + inRetval, I1: Integer;
  226 +begin
  227 + sgPath := ExpandFileName(FileName);
  228 + try
  229 + inRetval := FindFirst(ExpandFileName(FileName), faAnyFile, SearchRec);
  230 + if inRetval = 0 then
  231 + I1 := SearchRec.Size
  232 + else
  233 + I1 := -1;
  234 + finally
  235 + SysUtils.FindClose(SearchRec);
  236 + end;
  237 + Result := IntToStr(I1);
  238 +end;
  239 +
  240 +{*
  241 + Reads a file into a string and base64 encodes it.
  242 +
  243 + @param Base64String Base64 encoded string
  244 + @param LocalPath Path to load from
  245 + @param FileName FileName to read
  246 + @return base64 encoded string
  247 + @throws EKTWSAPI_Exception 'Could not access file to read.'
  248 +*}
  249 +function TKTWSAPI_FolderItem._LoadFileAsBase64String(FileName: WideString): WideString;
  250 +var
  251 + Stream: TFileStream;
  252 + InString: AnsiString;
  253 +begin
  254 + if not FileExists(FileName) then
  255 + raise EKTWSAPI_Exception.Create('Could not access file to read.');
  256 + Stream := TFileStream.Create(FileName, fmOpenRead);
  257 + try
  258 + SetLength(InString, Stream.Size);
  259 + Stream.ReadBuffer(InString[1], Length(InString));
  260 + Result := EncodeString(InString);
  261 + finally
  262 + Stream.Free;
  263 + end;
  264 +end;
  265 +
  266 +{*
  267 + Save a Base64 encoded string as a file.
  268 +
  269 + @param Base64String Base64 encoded string
  270 + @param LocalPath Path to save to
  271 + @param FileName FileName to save as
  272 + @return true if success
  273 +*}
  274 +function TKTWSAPI_FolderItem._SaveBase64StringAsFile(Base64String, LocalPath,
  275 + FileName: WideString): Boolean;
  276 +var
  277 + OutString: AnsiString;
  278 + Stream: TFileStream;
  279 + LocalFileName: String;
  280 +begin
  281 + LocalFileName := LocalPath + '/' + FileName;
  282 + OutString := DecodeString(Base64String);
  283 + Stream := TFileStream.Create(LocalFileName, fmCreate);
  284 + try
  285 + // For some reason it fails if I use WideString instead of AnsiString
  286 + Stream.WriteBuffer(Pointer(OutString)^, Length(OutString));
  287 + Result := true;
  288 + finally
  289 + Stream.Free;
  290 + end;
  291 +end;
  292 +
  293 +{*
  294 + Upload a file to KT.
  295 +
  296 + @param FileName Path to upload file
  297 + @param Action Which action to perform with the file (A = Add, C = Checkin)
  298 + @param DocumentId Id of the document
  299 + @return The temporary filename on the server
  300 + @throws EKTWSAPI_Exception Could not access file to upload.
  301 + @throws EKTWSAPI_Exception No response from server.
  302 + @throws EKTWSAPI_Exception Could not upload file.
  303 +*}
  304 +function TKTWSAPI_FolderItem._UploadFile(FileName, Action: WideString;
  305 + DocumentId: Integer): WideString;
  306 +var
  307 + UploadName, UploadStatus, SessionId, StatusCode: WideString;
  308 + PostStream: TIdMultiPartFormDataStream;
  309 + ResponseStream: TStringStream;
  310 + Fields: TStringList;
  311 + HTTP: TIdHTTP;
  312 + UploadData: TPHPValue;
  313 + FilesArr: TPHPArray;
  314 +begin
  315 + Result := '';
  316 + if not FileExists(FileName) then
  317 + raise EKTWSAPI_Exception.Create('Could not access file to upload.');
  318 + // TODO: Check if file is readable
  319 +
  320 + if (DocumentId = 0) then
  321 + UploadName := 'upload_document'
  322 + else
  323 + UploadName := 'upload_'+IntToStr(DocumentId);
  324 + SessionId := FKTAPI.Session;
  325 +
  326 + HTTP := TIdHttp.Create(nil);
  327 + try
  328 + PostStream := TIdMultiPartFormDataStream.Create;
  329 + ResponseStream := TStringStream.Create('');
  330 + Fields := TStringList.Create;
  331 + try
  332 + PostStream.AddFormField('session_id', SessionId);
  333 + PostStream.AddFormField('action', Action);
  334 + PostStream.AddFormField('document_id',IntToStr(DocumentId));
  335 + PostStream.AddFormField(UploadName,'@' + FileName);
  336 + PostStream.AddFile('file',FileName,GetMIMETypeFromFile(FileName));
  337 +
  338 + HTTP.Request.ContentType := PostStream.RequestContentType;
  339 + HTTP.Post(KTUploadURL, PostStream, ResponseStream);
  340 + if (ResponseStream.DataString = '') then
  341 + raise EKTWSAPI_Exception.Create('No response from server.');
  342 + ExtractStrings(['&'], [' '], pAnsiChar(ResponseStream.DataString), Fields);
  343 +
  344 + StatusCode := Copy(Fields[0], Pos('=',Fields[0])+1, 1);
  345 + if (StatusCode <> '0') then
  346 + raise EKTWSAPI_Exception.Create('Could not upload file.');
  347 +
  348 +
  349 + UploadStatus := Copy(Fields[1], Pos('=',Fields[1])+1, Length(Fields[1]));
  350 + UploadStatus := TIdURI.URLDecode(UploadStatus);
  351 + UploadData := TPHPSerialize.Unserialize(TIdURI.URLDecode(UploadStatus));
  352 + Assert(Assigned(UploadData));
  353 + Assert(Assigned(UploadData.AsArray['file']));
  354 + try
  355 + FilesArr := UploadData.AsArray['file'].AsArray;
  356 +
  357 + if (FilesArr['size'].AsString <> _GetFileSize(FileName)) then
  358 + raise EKTWSAPI_Exception.Create('Could not upload file.');
  359 +
  360 + Result := FilesArr['tmp_name'].AsString;
  361 + finally
  362 + UploadData.Free;
  363 + end;
  364 + finally
  365 + PostStream.Free;
  366 + ResponseStream.Free;
  367 + Fields.Free;
  368 + end;
  369 + finally
  370 + HTTP.Free;
  371 + end;
  372 +end;
  373 +
  374 +{*
  375 + Downloads a file from KT.
  376 +
  377 + @param Url Http-url to download
  378 + @param LocalPath Path to save to
  379 + @param FileName FileName to save as
  380 + @return true if success
  381 + @throws EKTWSAPI_Exception Could not create local file
  382 +*}
  383 +function TKTWSAPI_FolderItem._DownloadFile(Url, LocalPath,
  384 + FileName: WideString): Boolean;
  385 +var
  386 + Stream: TMemoryStream;
  387 + LocalFileName: WideString;
  388 + FP: File;
  389 + HTTP: TIdHTTP;
  390 +begin
  391 + LocalFileName := LocalPath + '/' + FileName;
  392 +
  393 + AssignFile(FP, LocalFileName);
  394 + {$I-}
  395 + Rewrite(FP,1);
  396 + {$I+}
  397 + if (IOResult <> 0) then
  398 + raise EKTWSAPI_Exception.Create('Could not create local file');
  399 + CloseFile(FP);
  400 + HTTP := TIdHttp.Create(Nil);
  401 + try
  402 + Stream := TMemoryStream.Create;
  403 + try
  404 + HTTP.Get(Url, Stream);
  405 + Stream.SaveToFile(LocalFileName);
  406 + Result := true;
  407 + finally
  408 + Stream.Free;
  409 + end;
  410 + finally
  411 + HTTP.Free;
  412 + end;
  413 +end;
  414 +
  415 +{*
  416 + Returns a reference to the parent folder.
  417 +
  418 + @return Handle to parent folder
  419 +*}
  420 +function TKTWSAPI_FolderItem.GetParentFolder: TKTWSAPI_Folder;
  421 +begin
  422 + Result := FKTAPI.GetFolderById(FParentId);
  423 +end;
  424 +
  425 +
  426 + { TKTWSAPI_Folder }
  427 +
  428 +{*
  429 + Constructor
  430 +
  431 + @param KTAPI Handle to KTAPI object
  432 + @param FolderDetail Handle to kt_folder_detail
  433 +*}
  434 +constructor TKTWSAPI_Folder.Create(KTAPI: TKTWSAPI;
  435 + FolderDetail: kt_folder_detail);
  436 +begin
  437 + FKTAPI := KTAPI;
  438 + FFolderId := FolderDetail.id;
  439 + FFolderName := FolderDetail.folder_name;
  440 + FParentId := FolderDetail.parent_id;
  441 + FFullPath := FolderDetail.full_path;
  442 +end;
  443 +
  444 +{*
  445 + Returns a reference to a TKTWSAPI_Folder
  446 +
  447 + @param KTAPI Handle to KTAPI object
  448 + @param FolderId Id of folder to fetch
  449 + @return folder handle
  450 + @throws EKTWSAPI_Exception Response message
  451 +*}
  452 +class function TKTWSAPI_Folder.Get(KTAPI: TKTWSAPI;
  453 + FolderId: Integer): TKTWSAPI_Folder;
  454 +var
  455 + FolderDetail: kt_folder_detail;
  456 +begin
  457 + Assert(Assigned(KTAPI));
  458 + Assert(KTAPI.ClassNameIs('TKTWSAPI'));
  459 + Result := nil;
  460 +
  461 + FolderDetail := KTAPI.SoapClient.get_folder_detail(KTAPI.Session, FolderId);
  462 + try
  463 + if (FolderDetail.status_code <> 0) then
  464 + raise EKTWSAPI_Exception.Create(FolderDetail.message_);
  465 +
  466 + Result := TKTWSAPI_Folder.Create(KTAPI, FolderDetail);
  467 +
  468 + finally
  469 + FolderDetail.Free;
  470 + end;
  471 +end;
  472 +
  473 +{*
  474 + Returns the parent folder id.
  475 +
  476 + @return parent folder id
  477 +*}
  478 +function TKTWSAPI_Folder.GetParentFolderId: Integer;
  479 +begin
  480 + Result := FParentId;
  481 +end;
  482 +
  483 +{*
  484 + Returns the folder name.
  485 +
  486 + @return folder name
  487 +*}
  488 +function TKTWSAPI_Folder.GetFolderName: WideString;
  489 +begin
  490 + Result := FFolderName;
  491 +end;
  492 +
  493 +{*
  494 + Returns the current folder id.
  495 +
  496 + @return current folder id
  497 +*}
  498 +function TKTWSAPI_Folder.GetFolderId: Integer;
  499 +begin
  500 + Result := FFolderId;
  501 +end;
  502 +
  503 +{*
  504 + Returns the folder based on foldername.
  505 +
  506 + @param FolderName Name of folder
  507 + @return folder handle
  508 + @throws EKTWSAPI_Exception Response message
  509 +*}
  510 +function TKTWSAPI_Folder.GetFolderByName(FolderName: WideString): TKTWSAPI_Folder;
  511 +var
  512 + Path: WideString;
  513 + FolderDetail: kt_folder_detail;
  514 +begin
  515 + Path := FFullPath + '/' + FolderName;
  516 + if (System.Copy(Path, 0, 13) = '/Root Folder/') then
  517 + Path := System.Copy(Path, 13, Length(Path)-1);
  518 + if (System.Copy(Path, 0, 12) = 'Root Folder/') then
  519 + Path := System.Copy(Path, 12, Length(Path)-1);
  520 +
  521 + FolderDetail := FKTAPI.SoapClient.get_folder_detail_by_name(FKTAPI.Session,
  522 + Path);
  523 +
  524 + if (FolderDetail.status_code <> 0) then
  525 + raise EKTWSAPI_Exception.Create(FolderDetail.message_);
  526 +
  527 + Result := TKTWSAPI_Folder.Create(FKTAPI, FolderDetail);
  528 +end;
  529 +
  530 +{*
  531 + Returns the full folder path.
  532 +
  533 + @return Full folder path
  534 +*}
  535 +function TKTWSAPI_Folder.GetFullPath: WideString;
  536 +begin
  537 + Result := FFullPath;
  538 +end;
  539 +
  540 +{*
  541 + Returns the contents of a folder.
  542 +
  543 + @param Depth How many sub-folders to fetch
  544 + @param What to fetch (F=Folders, D=Documents, FD=Both)
  545 + @return folder contents handle
  546 + @throws EKTWSAPI_Exception Response message
  547 +*}
  548 +function TKTWSAPI_Folder.GetListing(Depth: Integer;
  549 + What: WideString): kt_folder_contents;
  550 +begin
  551 + Result := FKTAPI.SoapClient.get_folder_contents(
  552 + FKTAPI.Session, FFolderId, Depth, What);
  553 +
  554 + if (Result.status_code <> 0) then
  555 + raise EKTWSAPI_Exception.Create(Result.message_);
  556 +end;
  557 +
  558 +{*
  559 + Returns a document based on title.
  560 +
  561 + @param Title Title of document
  562 + @return document handle
  563 + @throws EKTWSAPI_Exception Response message
  564 +*}
  565 +function TKTWSAPI_Folder.GetDocumentByName(Title: WideString): TKTWSAPI_Document;
  566 +var
  567 + Path: WideString;
  568 + DocumentDetail: kt_document_detail;
  569 +begin
  570 + Path := FFullPath + '/' + Title;
  571 + if (System.Copy(Path, 0, 13) = '/Root Folder/') then
  572 + Path := System.Copy(Path, 13, Length(Path)-1);
  573 + if (System.Copy(Path, 0, 12) = 'Root Folder/') then
  574 + Path := System.Copy(Path, 12, Length(Path)-1);
  575 +
  576 + DocumentDetail := FKTAPI.SoapClient.get_document_detail_by_name(FKTAPI.Session,
  577 + Path, 'T');
  578 +
  579 + if (DocumentDetail.status_code <> 0) then
  580 + raise EKTWSAPI_Exception.Create(DocumentDetail.message_);
  581 +
  582 + Result := TKTWSAPI_Document.Create(FKTAPI, DocumentDetail);
  583 +end;
  584 +
  585 +{*
  586 + Returns a document based on filename.
  587 +
  588 + @param FileName Name of file
  589 + @return document handle
  590 + @throws EKTWSAPI_Exception Response message
  591 +*}
  592 +function TKTWSAPI_Folder.GetDocumentByFileName(
  593 + FileName: WideString): TKTWSAPI_Document;
  594 +var
  595 + Path: WideString;
  596 + DocumentDetail: kt_document_detail;
  597 +begin
  598 + Result := nil;
  599 + Path := FFullPath + '/' + FileName;
  600 + if (System.Copy(Path, 0, 13) = '/Root Folder/') then
  601 + Path := System.Copy(Path, 13, Length(Path)-1);
  602 + if (System.Copy(Path, 0, 12) = 'Root Folder/') then
  603 + Path := System.Copy(Path, 12, Length(Path)-1);
  604 +
  605 + DocumentDetail := FKTAPI.SoapClient.get_document_detail_by_name(FKTAPI.Session,
  606 + Path, 'F');
  607 + try
  608 + if (DocumentDetail.status_code <> 0) then
  609 + raise EKTWSAPI_Exception.Create(DocumentDetail.message_);
  610 + Result := TKTWSAPI_Document.Create(FKTAPI, DocumentDetail);
  611 + finally
  612 + DocumentDetail.Free;
  613 + end;
  614 +end;
  615 +
  616 +{*
  617 + Adds a sub folder.
  618 +
  619 + @param FolderName Name of folder
  620 + @return new folder handle
  621 + @throws EKTWSAPI_Exception Response message
  622 +*}
  623 +function TKTWSAPI_Folder.AddFolder(FolderName: WideString): TKTWSAPI_Folder;
  624 +var
  625 + FolderDetail: kt_folder_detail;
  626 +begin
  627 + Result := nil;
  628 + FolderDetail := FKTAPI.SoapClient.create_folder(FKTAPI.Session, FFolderId, FolderName);
  629 + try
  630 + if (FolderDetail.status_code <> 0) then
  631 + raise EKTWSAPI_Exception.Create(FolderDetail.message_);
  632 +
  633 + Result := TKTWSAPI_Folder.Create(FKTAPI, FolderDetail);
  634 + finally
  635 + FolderDetail.Free;
  636 + end;
  637 +end;
  638 +
  639 +{*
  640 + Deletes the current folder.
  641 +
  642 + @param Reason Reason for deletetion
  643 + @return true
  644 + @throws EKTWSAPI_Exception Response message
  645 +*}
  646 +function TKTWSAPI_Folder.Delete(Reason: WideString): Boolean;
  647 +var
  648 + response: kt_response;
  649 +begin
  650 + // TODO: check why no transaction in folder_transactions
  651 + Result := System.False;
  652 + response := FKTAPI.SoapClient.delete_folder(FKTAPI.Session,
  653 + FFolderId, Reason);
  654 + try
  655 + if (response.status_code <> 0) then
  656 + raise EKTWSAPI_Exception.Create(response.message_);
  657 + Result := System.True;
  658 + finally
  659 + response.Free;
  660 + end;
  661 +end;
  662 +
  663 +{*
  664 + Renames the current folder.
  665 +
  666 + @param NewName New folder name
  667 + @return true
  668 + @throws EKTWSAPI_Exception Response message
  669 +*}
  670 +function TKTWSAPI_Folder.Rename(NewName: WideString): Boolean;
  671 +var
  672 + response: kt_response;
  673 +begin
  674 + Result := System.False;
  675 + response := FKTAPI.SoapClient.rename_folder(FKTAPI.Session,
  676 + FFolderId, NewName);
  677 + try
  678 + if (response.status_code <> 0) then
  679 + raise EKTWSAPI_Exception.Create(response.message_);
  680 + Result := System.True;
  681 + finally
  682 + response.Free;
  683 + end;
  684 +end;
  685 +
  686 +{*
  687 + Moves a folder to another location.
  688 +
  689 + @param TargetFolder Handle to target folder
  690 + @param Reason Reason for move
  691 + @return true
  692 + @throws EKTWSAPI_Exception Response message
  693 +*}
  694 +function TKTWSAPI_Folder.Move(TargetFolder: TKTWSAPI_Folder;
  695 + Reason: WideString): Boolean;
  696 +var
  697 + response: kt_response;
  698 +begin
  699 + Result := System.False;
  700 + Assert(Assigned(TargetFolder));
  701 + Assert(TargetFolder.ClassNameIs('TKTWSAPI_Folder'));
  702 +
  703 + response := FKTAPI.SoapClient.move_folder(FKTAPI.Session,
  704 + FFolderId, TargetFolder.GetFolderId, Reason);
  705 + try
  706 + if (response.status_code <> 0) then
  707 + raise EKTWSAPI_Exception.Create(response.message_);
  708 + Result := System.True;
  709 + finally
  710 + response.Free;
  711 + end;
  712 +end;
  713 +
  714 +{*
  715 + Copies a folder to another location
  716 +
  717 + @param TargetFolder Handle to target folder
  718 + @param Reason Reason for copy
  719 + @return true
  720 + @throws EKTWSAPI_Exception Response message
  721 +*}
  722 +function TKTWSAPI_Folder.Copy(TargetFolder: TKTWSAPI_Folder;
  723 + Reason: WideString): Boolean;
  724 +var
  725 + TargetId: Integer;
  726 + response: kt_response;
  727 +begin
  728 + Result := System.False;
  729 + Assert(Assigned(TargetFolder));
  730 + Assert(TargetFolder.ClassNameIs('TKTWSAPI_Folder'));
  731 +
  732 + TargetId := TargetFolder.GetFolderId;
  733 + response := FKTAPI.SoapClient.copy_folder(FKTAPI.Session,
  734 + FFolderId, TargetId, Reason);
  735 + try
  736 + if (response.status_code <> 0) then
  737 + raise EKTWSAPI_Exception.Create(response.message_);
  738 + Result := System.True;
  739 + finally
  740 + response.Free;
  741 + end;
  742 +end;
  743 +
  744 +{*
  745 + Adds a document to the current folder.
  746 +
  747 + @param FileName FileName to upload
  748 + @param Title Title to give document
  749 + @param DocumentType Documenttype of document (Default is 'Default')
  750 + @return handle to new document
  751 + @throws EKTWSAPI_Exception Response message
  752 +*}
  753 +function TKTWSAPI_Folder.AddDocument(FileName, Title,
  754 + DocumentType: WideString): TKTWSAPI_Document;
  755 +var
  756 + BaseName, TempFileName: WideString;
  757 + DocumentDetail: kt_document_detail;
  758 +begin
  759 + Result := nil;
  760 + BaseName := ExtractFileName(FileName);
  761 + if (Title = '') then
  762 + Title := BaseName;
  763 + if (DocumentType = '') then
  764 + DocumentType := 'Default';
  765 +
  766 + TempFileName := _UploadFile(FileName, 'A');
  767 + DocumentDetail := FKTAPI.FSoapClient.add_document(FKTAPI.Session, FFolderId,
  768 + Title, BaseName, DocumentType, TempFileName);
  769 + try
  770 + if (DocumentDetail.status_code <> 0) then
  771 + raise EKTWSAPI_Exception.Create(DocumentDetail.message_);
  772 +
  773 + Result := TKTWSAPI_Document.Create(FKTAPI, DocumentDetail);
  774 + finally
  775 + DocumentDetail.Free;
  776 + end;
  777 +end;
  778 +
  779 +{*
  780 + Adds a document to the current folder through web service.
  781 +
  782 + @param FileName FileName to upload
  783 + @param Title Title to give document
  784 + @param DocumentType Documenttype of document (Default is 'Default')
  785 + @return handle to new document
  786 + @throws EKTWSAPI_Exception Response message
  787 +*}
  788 +function TKTWSAPI_Folder.AddDocumentBase64(FileName, Title,
  789 + DocumentType: WideString): TKTWSAPI_Document;
  790 +begin
  791 + raise EKTWSAPI_Exception.Create('Not implemented yet!');
  792 +end;
  793 +
  794 +{ TKTWSAPI_Document }
  795 +
  796 +{*
  797 + Constructor
  798 +
  799 + @param KTAPI Handle to KTAPI object
  800 + @param DocumentDetail handle to kt_document_detail
  801 +*}
  802 +constructor TKTWSAPI_Document.Create(KTAPI: TKTWSAPI;
  803 + DocumentDetail: kt_document_detail);
  804 +begin
  805 + FKTAPI := KTAPI;
  806 + FDocumentId := DocumentDetail.document_id;
  807 + FTitle := DocumentDetail.title;
  808 + FDocumentType := DocumentDetail.document_type;
  809 + FVersion := DocumentDetail.version;
  810 + FFilename := DocumentDetail.filename;
  811 + FCreatedDate := DocumentDetail.created_date;
  812 + FCreatedBy := DocumentDetail.created_by;
  813 + FUpdatedDate := DocumentDetail.updated_date;
  814 + FUpdatedBy := DocumentDetail.updated_by;
  815 + FParentId := DocumentDetail.folder_id;
  816 + FWorkflow := DocumentDetail.workflow;
  817 + FWorkflowState := DocumentDetail.workflow_state;
  818 + FCheckoutBy := DocumentDetail.checkout_by;
  819 + FFullPath := DocumentDetail.full_path;
  820 +end;
  821 +
  822 +{*
  823 + Returns a reference to a document.
  824 +
  825 + @param KTAPI Handle to KTAPI object
  826 + @param DocumentId Id of document
  827 + @param LoadInfo Call web service to load document details
  828 + @return handle to document
  829 + @throws EKTWSAPI_Exception Response message
  830 +*}
  831 +class function TKTWSAPI_Document.Get(KTAPI: TKTWSAPI; DocumentId: Integer;
  832 + LoadInfo: Boolean): TKTWSAPI_Document;
  833 +var
  834 + DocumentDetail:kt_document_detail;
  835 +begin
  836 + Assert(Assigned(KTAPI));
  837 + Assert(KTAPI.ClassNameIs('TKTWSAPI'));
  838 + if LoadInfo then
  839 + begin
  840 + DocumentDetail := KTAPI.SoapClient.get_document_detail(KTAPI.Session, DocumentId);
  841 +
  842 + if (DocumentDetail.status_code <> 0) then
  843 + raise EKTWSAPI_Exception.Create(DocumentDetail.message_);
  844 +
  845 + end else
  846 + begin
  847 + DocumentDetail := kt_document_detail.Create;
  848 + DocumentDetail.document_id := DocumentId;
  849 + end;
  850 + try
  851 + Result := TKTWSAPI_Document.Create(KTAPI, DocumentDetail);
  852 + finally
  853 + DocumentDetail.Free;
  854 + end;
  855 +end;
  856 +
  857 +{*
  858 + Checks in a document.
  859 +
  860 + @param FileName Name of file to checkin
  861 + @param Reason Reason for checkin
  862 + @param MajorUpdate Checkin as a major update (bumps major version number)
  863 + @return true
  864 + @throws EKTWSAPI_Exception Response message
  865 +*}
  866 +function TKTWSAPI_Document.Checkin(FileName, Reason: WideString;
  867 + MajorUpdate: Boolean): Boolean;
  868 +var
  869 + BaseName, TempFileName: WideString;
  870 + response: kt_response;
  871 +begin
  872 + Result := System.False;
  873 + BaseName := ExtractFileName(FileName);
  874 +
  875 + TempFileName := _UploadFile(FileName, 'C', FDocumentId);
  876 + response := FKTAPI.SoapClient.checkin_document(FKTAPI.Session, FDocumentId, BaseName, Reason, TempFileName, MajorUpdate);
  877 + try
  878 + if (response.status_code <> 0) then
  879 + raise EKTWSAPI_Exception.Create(response.message_);
  880 + Result := System.True;
  881 + finally
  882 + response.Free;
  883 + end;
  884 +end;
  885 +
  886 +{*
  887 + Checks out a document.
  888 +
  889 + @param Reason Reason for checkout
  890 + @param LocalPath to save downloaded file to
  891 + @param DownloadFile if false then checkout will happen without download
  892 + @return true
  893 + @throws EKTWSAPI_Exception local path does not exist
  894 + @throws EKTWSAPI_Exception Response message
  895 +*}
  896 +function TKTWSAPI_Document.Checkout(Reason, LocalPath: WideString;
  897 + DownloadFile: Boolean): Boolean;
  898 +var
  899 + response: kt_response;
  900 + Url: WideString;
  901 +begin
  902 + Result := System.False;
  903 + if (LocalPath = '') then LocalPath := FKTAPI.GetDownloadPath;
  904 +
  905 + if not DirectoryExists(LocalPath) then
  906 + raise EKTWSAPI_Exception.Create('local path does not exist');
  907 +
  908 + // TODO check if Directory is writable
  909 +
  910 + response := FKTAPI.SoapClient.checkout_document(FKTAPI.Session, FDocumentId, Reason);
  911 + try
  912 + if (response.status_code <> 0) then
  913 + raise EKTWSAPI_Exception.Create(response.message_);
  914 +
  915 + Url := response.message_;
  916 +
  917 + if DownloadFile then
  918 + _DownloadFile(KTWebServerURL+Url, LocalPath, FFileName);
  919 +
  920 + Result := System.True;
  921 + finally
  922 + response.Free;
  923 + end;
  924 +end;
  925 +
  926 +{*
  927 + Undo a document checkout
  928 +
  929 + @param Reason Reason for undoing the checkout
  930 + @return true
  931 + @throws EKTWSAPI_Exception Response message
  932 +*}
  933 +function TKTWSAPI_Document.UndoCheckout(Reason: WideString): Boolean;
  934 +var
  935 + response: kt_response;
  936 +begin
  937 + Result := System.False;
  938 + response := FKTAPI.SoapClient.undo_document_checkout(FKTAPI.Session, FDocumentId, Reason);
  939 + try
  940 + if (response.status_code <> 0) then
  941 + raise EKTWSAPI_Exception.Create(response.message_);
  942 +
  943 + Result := System.True;
  944 + finally
  945 + response.Free;
  946 + end;
  947 +end;
  948 +
  949 +{*
  950 + Download a version of the document
  951 +
  952 + @param Version Which version of document to download
  953 + @param LocalPath Optional path to save file to
  954 + @param FileName Optional filename to save file as
  955 + @return true
  956 + @throws EKTWSAPI_Exception local path does not exist
  957 + @throws EKTWSAPI_Exception Response message
  958 +*}
  959 +function TKTWSAPI_Document.Download(Version, LocalPath, FileName: WideString): Boolean;
  960 +var
  961 + response: kt_response;
  962 + Url: WideString;
  963 +begin
  964 + Result := System.False;
  965 + if (LocalPath = '') then LocalPath := FKTAPI.GetDownloadPath;
  966 + if (FileName = '') then FileName := FFileName;
  967 +
  968 + if (not DirectoryExists(LocalPath)) then
  969 + raise EKTWSAPI_Exception.Create('local path does not exist');
  970 +
  971 + // TODO: Check if local path is writable
  972 +
  973 + response := FKTAPI.SoapClient.download_document(FKTAPI.Session, FDocumentId);
  974 + try
  975 + if (response.status_code <> 0) then
  976 + raise EKTWSAPI_Exception.Create(response.message_);
  977 + Url := response.message_;
  978 + Result := _DownloadFile(KTWebServerURL+Url, LocalPath, FileName);
  979 + finally
  980 + response.Free;
  981 + end;
  982 +end;
  983 +
  984 +
  985 +{*
  986 + Download a version of the document through webservice
  987 +
  988 + @param Version Which version of document to download
  989 + @param LocalPath Path to save file to
  990 + @return true
  991 + @throws EKTWSAPI_Exception Response message
  992 +*}
  993 +function TKTWSAPI_Document.DownloadBase64(Version,
  994 + LocalPath: WideString): Boolean;
  995 +var
  996 + response: kt_response;
  997 +begin
  998 + Result := System.False;
  999 + if (LocalPath = '') then LocalPath := FKTAPI.GetDownloadPath;
  1000 + if (FileName = '') then FileName := FFileName;
  1001 +
  1002 + if (not DirectoryExists(LocalPath)) then
  1003 + raise EKTWSAPI_Exception.Create('local path does not exist');
  1004 +
  1005 + // TODO: Check if local path is writable
  1006 +
  1007 + response := FKTAPI.SoapClient.download_base64_document(FKTAPI.Session, FDocumentId);
  1008 + try
  1009 + if (response.status_code <> 0) then
  1010 + raise EKTWSAPI_Exception.Create(response.message_);
  1011 + Result := _SaveBase64StringAsFile(response.message_, LocalPath, FileName);
  1012 + finally
  1013 + response.Free;
  1014 + end;
  1015 +end;
  1016 +
  1017 +{*
  1018 + Deletes the current document.
  1019 +
  1020 + @param Reason Reason for delete
  1021 + @return true
  1022 + @throws EKTWSAPI_Exception Response message
  1023 +*}
  1024 +function TKTWSAPI_Document.Delete(Reason: WideString): Boolean;
  1025 +var
  1026 + response: kt_response;
  1027 +begin
  1028 + Result := System.False;
  1029 + response := FKTAPI.SoapClient.delete_document(FKTAPI.Session, FDocumentId, Reason);
  1030 + try
  1031 + if (response.status_code <> 0) then
  1032 + raise EKTWSAPI_Exception.Create(response.message_);
  1033 +
  1034 + Result := System.True;
  1035 + finally
  1036 + response.Free;
  1037 + end;
  1038 +end;
  1039 +
  1040 +{*
  1041 + Changes the owner of the document.
  1042 +
  1043 + @param UserName Username of new owner
  1044 + @param Reason Reason for the owner change
  1045 + @return true
  1046 + @throws EKTWSAPI_Exception Response message
  1047 +*}
  1048 +function TKTWSAPI_Document.ChangeOwner(UserName, Reason: WideString): Boolean;
  1049 +var
  1050 + response: kt_response;
  1051 +begin
  1052 + Result := System.False;
  1053 + response := FKTAPI.SoapClient.change_document_owner(FKTAPI.Session, FDocumentId, UserName, Reason);
  1054 + try
  1055 + if (response.status_code <> 0) then
  1056 + raise EKTWSAPI_Exception.Create(response.message_);
  1057 +
  1058 + Result := System.True;
  1059 + finally
  1060 + response.Free;
  1061 + end;
  1062 +end;
  1063 +
  1064 +{*
  1065 + Copies the current document to the specified folder.
  1066 +
  1067 + @param Folder Handle to target folder
  1068 + @param Reason Reason for copy
  1069 + @param NewTitle New title of the file
  1070 + @param NewFileName New filename of the file
  1071 + @return true
  1072 + @throws EKTWSAPI_Exception Response message
  1073 +*}
  1074 +function TKTWSAPI_Document.Copy(Folder: TKTWSAPI_Folder; Reason, NewTitle,
  1075 + NewFileName: WideString): Boolean;
  1076 +var
  1077 + response: kt_response;
  1078 + FolderId: Integer;
  1079 +begin
  1080 + Result := System.False;
  1081 + Assert(Assigned(Folder));
  1082 + Assert(Folder.ClassNameIs('TKTWSAPI_Folder'));
  1083 + FolderId := Folder.GetFolderId;
  1084 +
  1085 + response := FKTAPI.SoapClient.copy_document(FKTAPI.Session, FDocumentId, FolderId, Reason, NewTitle, NewFileName);
  1086 + try
  1087 + if (response.status_code <> 0) then
  1088 + raise EKTWSAPI_Exception.Create(response.message_);
  1089 +
  1090 + Result := System.True;
  1091 + finally
  1092 + response.Free;
  1093 + end;
  1094 +end;
  1095 +
  1096 +{*
  1097 + Moves the current document to the specified folder.
  1098 +
  1099 + @param Folder Handle to target folder
  1100 + @param Reason Reason for move
  1101 + @param NewTitle New title of the file
  1102 + @param NewFileName New filename of the file
  1103 + @return true
  1104 + @throws EKTWSAPI_Exception Response message
  1105 +*}
  1106 +function TKTWSAPI_Document.Move(Folder: TKTWSAPI_Folder; Reason, NewTitle,
  1107 + NewFileName: WideString): Boolean;
  1108 +var
  1109 + response: kt_response;
  1110 + FolderId: Integer;
  1111 +begin
  1112 + Result := System.False;
  1113 + Assert(Assigned(Folder));
  1114 + Assert(Folder.ClassNameIs('TKTWSAPI_Folder'));
  1115 + FolderId := Folder.GetFolderId;
  1116 +
  1117 + response := FKTAPI.SoapClient.move_document(FKTAPI.Session, FDocumentId, FolderId, Reason, NewTitle, NewFileName);
  1118 + try
  1119 + if (response.status_code <> 0) then
  1120 + raise EKTWSAPI_Exception.Create(response.message_);
  1121 + Result := System.True;
  1122 + finally
  1123 + response.Free;
  1124 + end;
  1125 +end;
  1126 +
  1127 +{*
  1128 + Changes the document type.
  1129 +
  1130 + @param DocumentType DocumentType to change to
  1131 + @return true
  1132 + @throws EKTWSAPI_Exception Response message
  1133 +*}
  1134 +function TKTWSAPI_Document.ChangeDocumentType(DocumentType: WideString): Boolean;
  1135 +var
  1136 + response: kt_response;
  1137 +begin
  1138 + Result := System.False;
  1139 + response := FKTAPI.SoapClient.change_document_type(FKTAPI.Session, FDocumentId, DocumentType);
  1140 + try
  1141 + if (response.status_code <> 0) then
  1142 + raise EKTWSAPI_Exception.Create(response.message_);
  1143 +
  1144 + Result := System.True;
  1145 + finally
  1146 + response.Free;
  1147 + end;
  1148 +end;
  1149 +
  1150 +{*
  1151 + Renames the title of the current document.
  1152 +
  1153 + @param NewTitle New title of the document
  1154 + @return true
  1155 + @throws EKTWSAPI_Exception Response message
  1156 +*}
  1157 +function TKTWSAPI_Document.RenameTitle(NewTitle: WideString): Boolean;
  1158 +var
  1159 + response: kt_response;
  1160 +begin
  1161 + Result := System.False;
  1162 + response := FKTAPI.SoapClient.rename_document_title(FKTAPI.Session, FDocumentId, NewTitle);
  1163 + try
  1164 + if (response.status_code <> 0) then
  1165 + raise EKTWSAPI_Exception.Create(response.message_);
  1166 +
  1167 + Result := System.True;
  1168 + finally
  1169 + response.Free;
  1170 + end;
  1171 +end;
  1172 +
  1173 +{*
  1174 + Renames the filename of the current document.
  1175 +
  1176 + @param NewFilename New filename of the document
  1177 + @return true
  1178 +*}
  1179 +function TKTWSAPI_Document.RenameFilename(NewFilename: WideString): Boolean;
  1180 +var
  1181 + response: kt_response;
  1182 +begin
  1183 + Result := System.False;
  1184 + response := FKTAPI.SoapClient.rename_document_filename(FKTAPI.Session, FDocumentId, NewFilename);
  1185 + try
  1186 + if (response.status_code <> 0) then
  1187 + raise EKTWSAPI_Exception.Create(response.message_);
  1188 +
  1189 + Result := System.True;
  1190 + finally
  1191 + response.Free;
  1192 + end;
  1193 +end;
  1194 +
  1195 +{*
  1196 + Starts a workflow on the current document.
  1197 +
  1198 + @param WorkFlow Workflow
  1199 + @return true
  1200 + @throws EKTWSAPI_Exception Response message
  1201 +*}
  1202 +function TKTWSAPI_Document.StartWorkflow(WorkFlow: WideString): Boolean;
  1203 +var
  1204 + response: kt_response;
  1205 +begin
  1206 + Result := System.False;
  1207 + response := FKTAPI.SoapClient.start_document_workflow(FKTAPI.Session, FDocumentId, WorkFlow);
  1208 + try
  1209 + if (response.status_code <> 0) then
  1210 + raise EKTWSAPI_Exception.Create(response.message_);
  1211 +
  1212 + Result := System.True;
  1213 + finally
  1214 + response.Free;
  1215 + end;
  1216 +end;
  1217 +
  1218 +{*
  1219 + Removes the workflow process from the current document.
  1220 +
  1221 + @return true
  1222 + @throws EKTWSAPI_Exception Response message
  1223 +*}
  1224 +function TKTWSAPI_Document.DeleteWorkflow: Boolean;
  1225 +var
  1226 + response: kt_response;
  1227 +begin
  1228 + Result := System.False;
  1229 + response := FKTAPI.SoapClient.delete_document_workflow(FKTAPI.Session, FDocumentId);
  1230 + try
  1231 + if (response.status_code <> 0) then
  1232 + raise EKTWSAPI_Exception.Create(response.message_);
  1233 +
  1234 + Result := System.True;
  1235 + finally
  1236 + response.Free;
  1237 + end;
  1238 +end;
  1239 +
  1240 +{*
  1241 + Performs a transition on the current document.
  1242 +
  1243 + @param Transition Transition
  1244 + @param Reason Reason for transition
  1245 + @return true
  1246 + @throws EKTWSAPI_Exception Response message
  1247 +*}
  1248 +function TKTWSAPI_Document.PeformWorkflowTransition(Transition,
  1249 + Reason: WideString): Boolean;
  1250 +var
  1251 + response: kt_response;
  1252 +begin
  1253 + Result := System.False;
  1254 + response := FKTAPI.SoapClient.perform_document_workflow_transition(FKTAPI.Session, FDocumentId, Transition, Reason);
  1255 + try
  1256 + if (response.status_code <> 0) then
  1257 + raise EKTWSAPI_Exception.Create(response.message_);
  1258 +
  1259 + Result := System.True;
  1260 + finally
  1261 + response.Free;
  1262 + end;
  1263 +end;
  1264 +
  1265 +{*
  1266 + Returns metadata on the document.
  1267 +
  1268 + @return handle to metadata
  1269 + @throws EKTWSAPI_Exception Response message
  1270 +*}
  1271 +function TKTWSAPI_Document.GetMetadata: kt_metadata_response;
  1272 +begin
  1273 + Result := FKTAPI.SoapClient.get_document_metadata(FKTAPI.Session, FDocumentId);
  1274 +
  1275 + if (Result.status_code <> 0) then
  1276 + raise EKTWSAPI_Exception.Create(Result.message_);
  1277 +end;
  1278 +
  1279 +{*
  1280 + Updates the metadata on the current document.
  1281 +
  1282 + @param Metadata Handle to metadata
  1283 + @return true
  1284 + @throws EKTWSAPI_Exception Response message
  1285 +*}
  1286 +function TKTWSAPI_Document.UpdateMetadata(
  1287 + Metadata: kt_metadata_fieldsets): Boolean;
  1288 +var
  1289 + response: kt_response;
  1290 +begin
  1291 + Result := System.False;
  1292 + response := FKTAPI.SoapClient.update_document_metadata(FKTAPI.Session, FDocumentId, MetaData);
  1293 + try
  1294 + if (response.status_code <> 0) then
  1295 + raise EKTWSAPI_Exception.Create(response.message_);
  1296 +
  1297 + Result := System.True;
  1298 + finally
  1299 + response.Free;
  1300 + end;
  1301 +end;
  1302 +
  1303 +{*
  1304 + Returns the transaction history on the current document.
  1305 +
  1306 + @return handle to transaction history
  1307 + @throws EKTWSAPI_Exception Response message
  1308 +*}
  1309 +function TKTWSAPI_Document.GetTransactionHistory: kt_document_transaction_history_response;
  1310 +begin
  1311 + Result := FKTAPI.SoapClient.get_document_transaction_history(FKTAPI.Session, FDocumentId);
  1312 + if (Result.status_code <> 0) then
  1313 + raise EKTWSAPI_Exception.Create(Result.message_);
  1314 +end;
  1315 +
  1316 +{*
  1317 + Returns the version history on the current document.
  1318 +
  1319 + @return handle to document version history
  1320 + @throws EKTWSAPI_Exception Response message
  1321 +*}
  1322 +function TKTWSAPI_Document.GetVersionHistory: kt_document_version_history_response;
  1323 +begin
  1324 + Result := FKTAPI.SoapClient.get_document_version_history(FKTAPI.Session, FDocumentId);
  1325 + if (Result.status_code <> 0) then
  1326 + raise EKTWSAPI_Exception.Create(Result.message_);
  1327 +end;
  1328 +
  1329 +{*
  1330 + Returns the links of the current document
  1331 +
  1332 + @return handle to document version history
  1333 + @throws EKTWSAPI_Exception Response message
  1334 +*}
  1335 +function TKTWSAPI_Document.GetLinks: kt_linked_document_response;
  1336 +begin
  1337 + Result := FKTAPI.SoapClient.get_document_links(FKTAPI.Session, FDocumentId);
  1338 + if (Result.status_code <> 0) then
  1339 + raise EKTWSAPI_Exception.Create(Result.message_);
  1340 +end;
  1341 +
  1342 +{*
  1343 + Links the current document to a DocumentId
  1344 +
  1345 + @param DocumentId DocumentId to link to
  1346 + @param LinkType Type of link
  1347 + @return true
  1348 + @throws EKTWSAPI_Exception Response message
  1349 +*}
  1350 +function TKTWSAPI_Document.Link(DocumentId: Integer;
  1351 + const LinkType: WideString): Boolean;
  1352 +var
  1353 + response: kt_response;
  1354 +begin
  1355 + Result := System.False;
  1356 + response := FKTAPI.SoapClient.link_documents(FKTAPI.Session, FDocumentId,
  1357 + DocumentId, LinkType);
  1358 + try
  1359 + if (response.status_code <> 0) then
  1360 + raise EKTWSAPI_Exception.Create(response.message_);
  1361 + Result := System.True;
  1362 + finally
  1363 + response.Free;
  1364 + end;
  1365 +end;
  1366 +
  1367 +{*
  1368 + Unlinks the current document from a DocumentId
  1369 +
  1370 + @param DocumentId DocumentId to unlink to
  1371 + @return true
  1372 + @throws EKTWSAPI_Exception Response message
  1373 +*}
  1374 +function TKTWSAPI_Document.Unlink(DocumentId: Integer): Boolean;
  1375 +var
  1376 + response: kt_response;
  1377 +begin
  1378 + Result := System.False;
  1379 + response := FKTAPI.SoapClient.unlink_documents(FKTAPI.Session, FDocumentId,
  1380 + DocumentId);
  1381 + try
  1382 + if (response.status_code <> 0) then
  1383 + raise EKTWSAPI_Exception.Create(response.message_);
  1384 + Result := System.True;
  1385 + finally
  1386 + response.Free;
  1387 + end;
  1388 +end;
  1389 +
  1390 +{*
  1391 + Checks out a document and downloads document through webservice
  1392 +
  1393 + @param Reason Reason for checkout
  1394 + @param LocalPath to save downloaded file to
  1395 + @return true
  1396 + @throws EKTWSAPI_Exception local path does not exist
  1397 + @throws EKTWSAPI_Exception Response message
  1398 +*}
  1399 +function TKTWSAPI_Document.CheckoutBase64(Reason,
  1400 + LocalPath: WideString; DownloadFile: Boolean): Boolean;
  1401 +var
  1402 + response: kt_response;
  1403 +begin
  1404 + Result := System.False;
  1405 + if (LocalPath = '') then LocalPath := FKTAPI.GetDownloadPath;
  1406 +
  1407 + if not DirectoryExists(LocalPath) then
  1408 + raise EKTWSAPI_Exception.Create('local path does not exist');
  1409 +
  1410 + // TODO check if Directory is writable
  1411 +
  1412 + response := FKTAPI.SoapClient.checkout_base64_document(FKTAPI.Session, FDocumentId, Reason, DownloadFile);
  1413 + try
  1414 + if (response.status_code <> 0) then
  1415 + raise EKTWSAPI_Exception.Create(response.message_);
  1416 + Result := True;
  1417 + if DownloadFile then
  1418 + Result := _SaveBase64StringAsFile(response.message_, LocalPath, FFileName);
  1419 + finally
  1420 + response.Free;
  1421 + end;
  1422 +end;
  1423 +
  1424 +{*
  1425 + Gets list of document types
  1426 +
  1427 + @return handle to document types response
  1428 + @throws EKTWSAPI_Exception Response message
  1429 +*}
  1430 +function TKTWSAPI_Document.GetTypes: kt_document_types_response;
  1431 +begin
  1432 + Result := FKTAPI.SoapClient.get_document_types(FKTAPI.Session);
  1433 + if (Result.status_code <> 0) then
  1434 + raise EKTWSAPI_Exception.Create(Result.message_);
  1435 +end;
  1436 +
  1437 +{*
  1438 + Get list of document link types
  1439 + @return handle to document types response
  1440 + @throws EKTWSAPI_Exception Response message
  1441 +*}
  1442 +function TKTWSAPI_Document.GetLinkTypes: kt_document_types_response;
  1443 +begin
  1444 + Result := FKTAPI.SoapClient.get_document_link_types(FKTAPI.Session);
  1445 + if (Result.status_code <> 0) then
  1446 + raise EKTWSAPI_Exception.Create(Result.message_);
  1447 +end;
  1448 +
  1449 +{*
  1450 + Checks in a document and uploads through webservice
  1451 +
  1452 + @param FileName Name of file to checkin
  1453 + @param Reason Reason for checkin
  1454 + @param MajorUpdate Checkin as a major update (bumps major version number)
  1455 + @return true
  1456 + @throws EKTWSAPI_Exception Response message
  1457 +*}
  1458 +function TKTWSAPI_Document.CheckinBase64(FileName, Reason: WideString;
  1459 + MajorUpdate: Boolean): Boolean;
  1460 +var
  1461 + Base64String, BaseName: WideString;
  1462 + response: kt_response;
  1463 +begin
  1464 + Result := System.False;
  1465 + Base64String := _LoadFileAsBase64String(FileName);
  1466 + BaseName := ExtractFileName(FileName);
  1467 +
  1468 + response := FKTAPI.SoapClient.checkin_base64_document(FKTAPI.Session,
  1469 + FDocumentId, BaseName, Reason, Base64String, MajorUpdate);
  1470 + try
  1471 + if (response.status_code <> 0) then
  1472 + raise EKTWSAPI_Exception.Create(response.message_);
  1473 + Result := System.True;
  1474 + finally
  1475 + response.Free;
  1476 + end;
  1477 +end;
  1478 +
  1479 +{ TKTWSAPI }
  1480 +
  1481 +{*
  1482 + Constructor
  1483 +*}
  1484 +constructor Tktwsapi.Create();
  1485 +begin
  1486 + FSoapClient := GetKnowledgeTreePort(False, KTWebServiceUrl);
  1487 + FDownloadPath := '';
  1488 +end;
  1489 +
  1490 +{*
  1491 + This returns the default location where documents are downloaded in download() and checkout().
  1492 +
  1493 + @return string
  1494 +*}
  1495 +function TKTWSAPI.GetDownloadPath: WideString;
  1496 +begin
  1497 + Result := FDownloadPath;
  1498 +end;
  1499 +
  1500 +{*
  1501 + Allows the default location for downloaded documents to be changed.
  1502 +
  1503 + @param DownloadPath Path to writable folder
  1504 + @return true
  1505 +*}
  1506 +function TKTWSAPI.SetDownloadPath(DownloadPath: WideString): Boolean;
  1507 +begin
  1508 + if (not DirectoryExists(DownloadPath)) then
  1509 + raise EKTWSAPI_Exception.Create('local path is not writable');
  1510 + // TODO : Check if folder is writable
  1511 +
  1512 + FDownloadPath := DownloadPath;
  1513 + Result := System.True;
  1514 +end;
  1515 +
  1516 +{*
  1517 + Starts an anonymous session.
  1518 +
  1519 + @param Ip Users Ip-adress
  1520 + @return Active session id
  1521 +*}
  1522 +function TKTWSAPI.StartAnonymousSession(Ip: WideString): WideString;
  1523 +begin
  1524 + Result := StartSession('anonymous', '', Ip);
  1525 +end;
  1526 +
  1527 +{*
  1528 + Starts a user session.
  1529 +
  1530 + @param Username Users username
  1531 + @param Password Users password
  1532 + @param Ip Users Ip-adress
  1533 + @return Active session id
  1534 + @throws EKTWSAPI_Exception KTWSAPI_ERR_SESSION_IN_USE
  1535 + @throws EKTWSAPI_Exception Response message
  1536 +*}
  1537 +function TKTWSAPI.StartSession(Username, Password, Ip: WideString): WideString;
  1538 +var
  1539 + response: kt_response;
  1540 +begin
  1541 + if (FSession <> '') then
  1542 + raise EKTWSAPI_Exception.Create(KTWSAPI_ERR_SESSION_IN_USE);
  1543 + response := FSoapClient.login(Username, Password, Ip);
  1544 + try
  1545 + if (response.status_code <> 0) then
  1546 + raise EKTWSAPI_Exception.Create(response.message_);
  1547 + FSession := response.message_;
  1548 + Result := FSession;
  1549 + finally
  1550 + response.Free;
  1551 + end;
  1552 +end;
  1553 +
  1554 +{*
  1555 + Sets an active session.
  1556 +
  1557 + @param Session Session id to activate
  1558 + @param Ip Users Ip-adress
  1559 + @return Active session id
  1560 + @throws EKTWSAPI_Exception KTWSAPI_ERR_SESSION_IN_USE
  1561 +*}
  1562 +function TKTWSAPI.ActiveSession(Session, Ip: WideString): WideString;
  1563 +begin
  1564 + if (FSession <> '') then
  1565 + raise EKTWSAPI_Exception.Create(KTWSAPI_ERR_SESSION_IN_USE);
  1566 + FSession := Session;
  1567 + Result := FSession;
  1568 +end;
  1569 +
  1570 +{*
  1571 + Closes an active session.
  1572 +
  1573 + @return true
  1574 +*}
  1575 +function TKTWSAPI.Logout: Boolean;
  1576 +var
  1577 + response: kt_response;
  1578 +begin
  1579 + Result := System.False;
  1580 +
  1581 + if (FSession = '') then
  1582 + raise EKTWSAPI_Exception.Create(KTWSAPI_ERR_SESSION_NOT_STARTED);
  1583 + response := FSoapClient.logout(FSession);
  1584 + try
  1585 + if (response.status_code <> 0) then
  1586 + raise EKTWSAPI_Exception.Create(response.message_);
  1587 + FSession := '';
  1588 + Result := System.True;
  1589 + finally
  1590 + response.Free;
  1591 + end;
  1592 +end;
  1593 +
  1594 +{*
  1595 + Returns a reference to the root folder.
  1596 +
  1597 + @return handle to folder
  1598 +*}
  1599 +function TKTWSAPI.GetRootFolder: TKTWSAPI_Folder;
  1600 +begin
  1601 + Result := GetFolderById(1);
  1602 +end;
  1603 +
  1604 +{*
  1605 + Returns a reference to a folder based on id.
  1606 +
  1607 + @param FolderId Id of folder
  1608 + @return handle to folder
  1609 +*}
  1610 +function TKTWSAPI.GetFolderById(FolderId: Integer): TKTWSAPI_Folder;
  1611 +begin
  1612 + if FSession = '' then
  1613 + raise EKTWSAPI_Exception.Create('A session is not active');
  1614 + Result := TKTWSAPI_Folder.Get(Self, FolderId);
  1615 +end;
  1616 +
  1617 +{*
  1618 + Returns a reference to a document based on id.
  1619 +
  1620 + @param DocumentId Id of document
  1621 + @return handle to document
  1622 +*}
  1623 +function TKTWSAPI.GetDocumentById(DocumentId: Integer): TKTWSAPI_Document;
  1624 +begin
  1625 + if FSession = '' then
  1626 + raise EKTWSAPI_Exception.Create('A session is not active');
  1627 + Result := TKTWSAPI_Document.Get(Self, DocumentId)
  1628 +end;
  1629 +
  1630 +end.
... ...
ktwsapi/delphi/uwebservice.pas 0 → 100644
  1 +{
  2 + Copyright (c) 2007, The Jam Warehouse Software (Pty) Ltd.
  3 +
  4 + All rights reserved.
  5 +
  6 + Redistribution and use in source and binary forms, with or without
  7 + modification, are permitted provided that the following conditions are met:
  8 +
  9 + i) Redistributions of source code must retain the above copyright notice,
  10 + this list of conditions and the following disclaimer.
  11 + ii) Redistributions in binary form must reproduce the above copyright
  12 + notice, this list of conditions and the following disclaimer in the
  13 + documentation and/or other materials provided with the distribution.
  14 + iii) Neither the name of the The Jam Warehouse Software (Pty) Ltd nor the
  15 + names of its contributors may be used to endorse or promote products
  16 + derived from this software without specific prior written permission.
  17 +
  18 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19 + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20 + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21 + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  22 + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  23 + EXEMPLARY, OR CONSEQUENTIAL DAMAGES ( INCLUDING, BUT NOT LIMITED TO,
  24 + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  25 + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  26 + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ( INCLUDING
  27 + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28 + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29 +}
  30 +
  31 +{*
  32 + Unit auto-generated by delphi's wsdl imported
  33 +
  34 + @Author Bjarte Kalstveit Vebjørnsen <bjarte@macaos.com>
  35 + @Version 1.0 BKV 24.09.2007 Initial revision
  36 +*}
  37 +
  38 +// ************************************************************************ //
  39 +// The types declared in this file were generated from data read from the
  40 +// WSDL File described below:
  41 +// WSDL : http://ktdms.trunk/ktwebservice/webservice.php?wsdl
  42 +// Codegen : [wfDebug,wfGenerateWarnings,wfUseSerializerClassForAttrs]
  43 +// Version : 1.0
  44 +// (23.09.2007 21:20:12 - 1.33.2.6)
  45 +// ************************************************************************ //
  46 +
  47 +unit uwebservice;
  48 +
  49 +interface
  50 +
  51 +uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;
  52 +
  53 +type
  54 +
  55 + // ************************************************************************ //
  56 + // The following types, referred to in the WSDL document are not being represented
  57 + // in this file. They are either aliases[@] of other types represented or were referred
  58 + // to but never[!] declared in the document. The types from the latter category
  59 + // typically map to predefined/known XML or Borland types; however, they could also
  60 + // indicate incorrect WSDL documents that failed to declare or import a schema type.
  61 + // ************************************************************************ //
  62 + // !:int - "http://www.w3.org/2001/XMLSchema"
  63 + // !:string - "http://www.w3.org/2001/XMLSchema"
  64 + // !:boolean - "http://www.w3.org/2001/XMLSchema"
  65 +
  66 + kt_response = class; { "urn:KnowledgeTree" }
  67 + kt_folder_detail = class; { "urn:KnowledgeTree" }
  68 + kt_folder_item = class; { "urn:KnowledgeTree" }
  69 + kt_folder_contents = class; { "urn:KnowledgeTree" }
  70 + kt_document_detail = class; { "urn:KnowledgeTree" }
  71 + kt_metadata_selection_item = class; { "urn:KnowledgeTree" }
  72 + kt_metadata_field = class; { "urn:KnowledgeTree" }
  73 + kt_metadata_fieldset = class; { "urn:KnowledgeTree" }
  74 + kt_metadata_response = class; { "urn:KnowledgeTree" }
  75 + kt_document_transitions_response = class; { "urn:KnowledgeTree" }
  76 + kt_document_transaction_history_item = class; { "urn:KnowledgeTree" }
  77 + kt_linked_document = class; { "urn:KnowledgeTree" }
  78 + kt_linked_document_response = class; { "urn:KnowledgeTree" }
  79 + kt_document_transaction_history_response = class; { "urn:KnowledgeTree" }
  80 + kt_document_version_history_item = class; { "urn:KnowledgeTree" }
  81 + kt_document_version_history_response = class; { "urn:KnowledgeTree" }
  82 + kt_document_types_response = class; { "urn:KnowledgeTree" }
  83 +
  84 +
  85 +
  86 + // ************************************************************************ //
  87 + // Namespace : urn:KnowledgeTree
  88 + // ************************************************************************ //
  89 + kt_response = class(TRemotable)
  90 + private
  91 + Fstatus_code: Integer;
  92 + Fmessage_: WideString;
  93 + published
  94 + property status_code: Integer read Fstatus_code write Fstatus_code;
  95 + property message_: WideString read Fmessage_ write Fmessage_;
  96 + end;
  97 +
  98 +
  99 +
  100 + // ************************************************************************ //
  101 + // Namespace : urn:KnowledgeTree
  102 + // ************************************************************************ //
  103 + kt_folder_detail = class(TRemotable)
  104 + private
  105 + Fstatus_code: Integer;
  106 + Fmessage_: WideString;
  107 + Fid: Integer;
  108 + Ffolder_name: WideString;
  109 + Fparent_id: Integer;
  110 + Ffull_path: WideString;
  111 + published
  112 + property status_code: Integer read Fstatus_code write Fstatus_code;
  113 + property message_: WideString read Fmessage_ write Fmessage_;
  114 + property id: Integer read Fid write Fid;
  115 + property folder_name: WideString read Ffolder_name write Ffolder_name;
  116 + property parent_id: Integer read Fparent_id write Fparent_id;
  117 + property full_path: WideString read Ffull_path write Ffull_path;
  118 + end;
  119 +
  120 + kt_folder_items = array of kt_folder_item; { "urn:KnowledgeTree" }
  121 +
  122 +
  123 + // ************************************************************************ //
  124 + // Namespace : urn:KnowledgeTree
  125 + // ************************************************************************ //
  126 + kt_folder_item = class(TRemotable)
  127 + private
  128 + Fid: Integer;
  129 + Fitem_type: WideString;
  130 + Ftitle: WideString;
  131 + Fcreator: WideString;
  132 + Fchecked_out_by: WideString;
  133 + Fmodified_by: WideString;
  134 + Ffilename: WideString;
  135 + Fsize: WideString;
  136 + Fmajor_version: WideString;
  137 + Fminor_version: WideString;
  138 + Fstorage_path: WideString;
  139 + Fmime_type: WideString;
  140 + Fmime_icon_path: WideString;
  141 + Fmime_display: WideString;
  142 + Fworkflow: WideString;
  143 + Fworkflow_state: WideString;
  144 + Fitems: kt_folder_items;
  145 + public
  146 + destructor Destroy; override;
  147 + published
  148 + property id: Integer read Fid write Fid;
  149 + property item_type: WideString read Fitem_type write Fitem_type;
  150 + property title: WideString read Ftitle write Ftitle;
  151 + property creator: WideString read Fcreator write Fcreator;
  152 + property checked_out_by: WideString read Fchecked_out_by write Fchecked_out_by;
  153 + property modified_by: WideString read Fmodified_by write Fmodified_by;
  154 + property filename: WideString read Ffilename write Ffilename;
  155 + property size: WideString read Fsize write Fsize;
  156 + property major_version: WideString read Fmajor_version write Fmajor_version;
  157 + property minor_version: WideString read Fminor_version write Fminor_version;
  158 + property storage_path: WideString read Fstorage_path write Fstorage_path;
  159 + property mime_type: WideString read Fmime_type write Fmime_type;
  160 + property mime_icon_path: WideString read Fmime_icon_path write Fmime_icon_path;
  161 + property mime_display: WideString read Fmime_display write Fmime_display;
  162 + property workflow: WideString read Fworkflow write Fworkflow;
  163 + property workflow_state: WideString read Fworkflow_state write Fworkflow_state;
  164 + property items: kt_folder_items read Fitems write Fitems;
  165 + end;
  166 +
  167 +
  168 +
  169 + // ************************************************************************ //
  170 + // Namespace : urn:KnowledgeTree
  171 + // ************************************************************************ //
  172 + kt_folder_contents = class(TRemotable)
  173 + private
  174 + Fstatus_code: Integer;
  175 + Fmessage_: WideString;
  176 + Ffolder_id: Integer;
  177 + Ffolder_name: WideString;
  178 + Ffull_path: WideString;
  179 + Fitems: kt_folder_items;
  180 + public
  181 + destructor Destroy; override;
  182 + published
  183 + property status_code: Integer read Fstatus_code write Fstatus_code;
  184 + property message_: WideString read Fmessage_ write Fmessage_;
  185 + property folder_id: Integer read Ffolder_id write Ffolder_id;
  186 + property folder_name: WideString read Ffolder_name write Ffolder_name;
  187 + property full_path: WideString read Ffull_path write Ffull_path;
  188 + property items: kt_folder_items read Fitems write Fitems;
  189 + end;
  190 +
  191 +
  192 +
  193 + // ************************************************************************ //
  194 + // Namespace : urn:KnowledgeTree
  195 + // ************************************************************************ //
  196 + kt_document_detail = class(TRemotable)
  197 + private
  198 + Fstatus_code: Integer;
  199 + Fmessage_: WideString;
  200 + Ftitle: WideString;
  201 + Fdocument_type: WideString;
  202 + Fversion: WideString;
  203 + Ffilename: WideString;
  204 + Fcreated_date: WideString;
  205 + Fcreated_by: WideString;
  206 + Fupdated_date: WideString;
  207 + Fupdated_by: WideString;
  208 + Fdocument_id: Integer;
  209 + Ffolder_id: Integer;
  210 + Fworkflow: WideString;
  211 + Fworkflow_state: WideString;
  212 + Fcheckout_by: WideString;
  213 + Ffull_path: WideString;
  214 + published
  215 + property status_code: Integer read Fstatus_code write Fstatus_code;
  216 + property message_: WideString read Fmessage_ write Fmessage_;
  217 + property title: WideString read Ftitle write Ftitle;
  218 + property document_type: WideString read Fdocument_type write Fdocument_type;
  219 + property version: WideString read Fversion write Fversion;
  220 + property filename: WideString read Ffilename write Ffilename;
  221 + property created_date: WideString read Fcreated_date write Fcreated_date;
  222 + property created_by: WideString read Fcreated_by write Fcreated_by;
  223 + property updated_date: WideString read Fupdated_date write Fupdated_date;
  224 + property updated_by: WideString read Fupdated_by write Fupdated_by;
  225 + property document_id: Integer read Fdocument_id write Fdocument_id;
  226 + property folder_id: Integer read Ffolder_id write Ffolder_id;
  227 + property workflow: WideString read Fworkflow write Fworkflow;
  228 + property workflow_state: WideString read Fworkflow_state write Fworkflow_state;
  229 + property checkout_by: WideString read Fcheckout_by write Fcheckout_by;
  230 + property full_path: WideString read Ffull_path write Ffull_path;
  231 + end;
  232 +
  233 +
  234 +
  235 + // ************************************************************************ //
  236 + // Namespace : urn:KnowledgeTree
  237 + // ************************************************************************ //
  238 + kt_metadata_selection_item = class(TRemotable)
  239 + private
  240 + Fid: Integer;
  241 + Fname_: WideString;
  242 + Fvalue: WideString;
  243 + Fparent_id: Integer;
  244 + published
  245 + property id: Integer read Fid write Fid;
  246 + property name_: WideString read Fname_ write Fname_;
  247 + property value: WideString read Fvalue write Fvalue;
  248 + property parent_id: Integer read Fparent_id write Fparent_id;
  249 + end;
  250 +
  251 + kt_metadata_selection = array of kt_metadata_selection_item; { "urn:KnowledgeTree" }
  252 +
  253 +
  254 + // ************************************************************************ //
  255 + // Namespace : urn:KnowledgeTree
  256 + // ************************************************************************ //
  257 + kt_metadata_field = class(TRemotable)
  258 + private
  259 + Fname_: WideString;
  260 + Frequired: Boolean;
  261 + Fvalue: WideString;
  262 + Fdescription: WideString;
  263 + Fcontrol_type: WideString;
  264 + Fselection: kt_metadata_selection;
  265 + public
  266 + destructor Destroy; override;
  267 + published
  268 + property name_: WideString read Fname_ write Fname_;
  269 + property required: Boolean read Frequired write Frequired;
  270 + property value: WideString read Fvalue write Fvalue;
  271 + property description: WideString read Fdescription write Fdescription;
  272 + property control_type: WideString read Fcontrol_type write Fcontrol_type;
  273 + property selection: kt_metadata_selection read Fselection write Fselection;
  274 + end;
  275 +
  276 + kt_metadata_fields = array of kt_metadata_field; { "urn:KnowledgeTree" }
  277 +
  278 +
  279 + // ************************************************************************ //
  280 + // Namespace : urn:KnowledgeTree
  281 + // ************************************************************************ //
  282 + kt_metadata_fieldset = class(TRemotable)
  283 + private
  284 + Ffieldset: WideString;
  285 + Fdescription: WideString;
  286 + Ffields: kt_metadata_fields;
  287 + public
  288 + destructor Destroy; override;
  289 + published
  290 + property fieldset: WideString read Ffieldset write Ffieldset;
  291 + property description: WideString read Fdescription write Fdescription;
  292 + property fields: kt_metadata_fields read Ffields write Ffields;
  293 + end;
  294 +
  295 + kt_metadata_fieldsets = array of kt_metadata_fieldset; { "urn:KnowledgeTree" }
  296 +
  297 +
  298 + // ************************************************************************ //
  299 + // Namespace : urn:KnowledgeTree
  300 + // ************************************************************************ //
  301 + kt_metadata_response = class(TRemotable)
  302 + private
  303 + Fstatus_code: Integer;
  304 + Fmessage_: WideString;
  305 + Fmetadata: kt_metadata_fieldsets;
  306 + public
  307 + destructor Destroy; override;
  308 + published
  309 + property status_code: Integer read Fstatus_code write Fstatus_code;
  310 + property message_: WideString read Fmessage_ write Fmessage_;
  311 + property metadata: kt_metadata_fieldsets read Fmetadata write Fmetadata;
  312 + end;
  313 +
  314 + kt_document_transitions = array of WideString; { "urn:KnowledgeTree" }
  315 +
  316 +
  317 + // ************************************************************************ //
  318 + // Namespace : urn:KnowledgeTree
  319 + // ************************************************************************ //
  320 + kt_document_transitions_response = class(TRemotable)
  321 + private
  322 + Fstatus_code: Integer;
  323 + Fmessage_: WideString;
  324 + Fmetadata: kt_document_transitions;
  325 + published
  326 + property status_code: Integer read Fstatus_code write Fstatus_code;
  327 + property message_: WideString read Fmessage_ write Fmessage_;
  328 + property metadata: kt_document_transitions read Fmetadata write Fmetadata;
  329 + end;
  330 +
  331 +
  332 +
  333 + // ************************************************************************ //
  334 + // Namespace : urn:KnowledgeTree
  335 + // ************************************************************************ //
  336 + kt_document_transaction_history_item = class(TRemotable)
  337 + private
  338 + Ftransaction_name: WideString;
  339 + Fusername: WideString;
  340 + Fversion: WideString;
  341 + Fcomment: WideString;
  342 + Fdatetime: WideString;
  343 + published
  344 + property transaction_name: WideString read Ftransaction_name write Ftransaction_name;
  345 + property username: WideString read Fusername write Fusername;
  346 + property version: WideString read Fversion write Fversion;
  347 + property comment: WideString read Fcomment write Fcomment;
  348 + property datetime: WideString read Fdatetime write Fdatetime;
  349 + end;
  350 +
  351 +
  352 +
  353 + // ************************************************************************ //
  354 + // Namespace : urn:KnowledgeTree
  355 + // ************************************************************************ //
  356 + kt_linked_document = class(TRemotable)
  357 + private
  358 + Fdocument_id: Integer;
  359 + Ftitle: WideString;
  360 + Fsize: Integer;
  361 + Fworkflow: WideString;
  362 + Fworkflow_state: WideString;
  363 + Flink_type: WideString;
  364 + published
  365 + property document_id: Integer read Fdocument_id write Fdocument_id;
  366 + property title: WideString read Ftitle write Ftitle;
  367 + property size: Integer read Fsize write Fsize;
  368 + property workflow: WideString read Fworkflow write Fworkflow;
  369 + property workflow_state: WideString read Fworkflow_state write Fworkflow_state;
  370 + property link_type: WideString read Flink_type write Flink_type;
  371 + end;
  372 +
  373 + kt_linked_documents = array of kt_linked_document; { "urn:KnowledgeTree" }
  374 +
  375 +
  376 + // ************************************************************************ //
  377 + // Namespace : urn:KnowledgeTree
  378 + // ************************************************************************ //
  379 + kt_linked_document_response = class(TRemotable)
  380 + private
  381 + Fstatus_code: Integer;
  382 + Fmessage_: WideString;
  383 + Fparent_document_id: WideString;
  384 + Flinks: kt_linked_documents;
  385 + public
  386 + destructor Destroy; override;
  387 + published
  388 + property status_code: Integer read Fstatus_code write Fstatus_code;
  389 + property message_: WideString read Fmessage_ write Fmessage_;
  390 + property parent_document_id: WideString read Fparent_document_id write Fparent_document_id;
  391 + property links: kt_linked_documents read Flinks write Flinks;
  392 + end;
  393 +
  394 + kt_document_transaction_history = array of kt_document_transaction_history_item; { "urn:KnowledgeTree" }
  395 +
  396 +
  397 + // ************************************************************************ //
  398 + // Namespace : urn:KnowledgeTree
  399 + // ************************************************************************ //
  400 + kt_document_transaction_history_response = class(TRemotable)
  401 + private
  402 + Fstatus_code: Integer;
  403 + Fmessage_: WideString;
  404 + Fhistory: kt_document_transaction_history;
  405 + public
  406 + destructor Destroy; override;
  407 + published
  408 + property status_code: Integer read Fstatus_code write Fstatus_code;
  409 + property message_: WideString read Fmessage_ write Fmessage_;
  410 + property history: kt_document_transaction_history read Fhistory write Fhistory;
  411 + end;
  412 +
  413 +
  414 +
  415 + // ************************************************************************ //
  416 + // Namespace : urn:KnowledgeTree
  417 + // ************************************************************************ //
  418 + kt_document_version_history_item = class(TRemotable)
  419 + private
  420 + Fuser: Integer;
  421 + Fmetadata_version: WideString;
  422 + Fcontent_version: WideString;
  423 + published
  424 + property user: Integer read Fuser write Fuser;
  425 + property metadata_version: WideString read Fmetadata_version write Fmetadata_version;
  426 + property content_version: WideString read Fcontent_version write Fcontent_version;
  427 + end;
  428 +
  429 + kt_document_version_history = array of kt_document_version_history_item; { "urn:KnowledgeTree" }
  430 +
  431 +
  432 + // ************************************************************************ //
  433 + // Namespace : urn:KnowledgeTree
  434 + // ************************************************************************ //
  435 + kt_document_version_history_response = class(TRemotable)
  436 + private
  437 + Fstatus_code: Integer;
  438 + Fmessage_: WideString;
  439 + Fhistory: kt_document_version_history;
  440 + public
  441 + destructor Destroy; override;
  442 + published
  443 + property status_code: Integer read Fstatus_code write Fstatus_code;
  444 + property message_: WideString read Fmessage_ write Fmessage_;
  445 + property history: kt_document_version_history read Fhistory write Fhistory;
  446 + end;
  447 +
  448 + kt_document_types_array = array of WideString; { "urn:KnowledgeTree" }
  449 +
  450 +
  451 + // ************************************************************************ //
  452 + // Namespace : urn:KnowledgeTree
  453 + // ************************************************************************ //
  454 + kt_document_types_response = class(TRemotable)
  455 + private
  456 + Fstatus_code: Integer;
  457 + Fmessage_: WideString;
  458 + Fdocument_types: kt_document_types_array;
  459 + published
  460 + property status_code: Integer read Fstatus_code write Fstatus_code;
  461 + property message_: WideString read Fmessage_ write Fmessage_;
  462 + property document_types: kt_document_types_array read Fdocument_types write Fdocument_types;
  463 + end;
  464 +
  465 +
  466 + // ************************************************************************ //
  467 + // Namespace : http://schemas.xmlsoap.org/soap/envelope/
  468 + // soapAction: http://schemas.xmlsoap.org/soap/envelope/#KTWebService#%operationName%
  469 + // transport : http://schemas.xmlsoap.org/soap/http
  470 + // style : rpc
  471 + // binding : KnowledgeTreeBinding
  472 + // service : KnowledgeTreeService
  473 + // port : KnowledgeTreePort
  474 + // URL : http://ktdms.trunk/ktwebservice/webservice.php
  475 + // ************************************************************************ //
  476 + KnowledgeTreePort = interface(IInvokable)
  477 + ['{FA35CA60-1DC3-B3C7-6C65-BE4E3A6A8A22}']
  478 + function login(const username: WideString; const password: WideString; const ip: WideString): kt_response; stdcall;
  479 + function anonymous_login(const ip: WideString): kt_response; stdcall;
  480 + function logout(const session_id: WideString): kt_response; stdcall;
  481 + function get_folder_detail(const session_id: WideString; const folder_id: Integer): kt_folder_detail; stdcall;
  482 + function get_folder_detail_by_name(const session_id: WideString; const folder_name: WideString): kt_folder_detail; stdcall;
  483 + function get_folder_contents(const session_id: WideString; const folder_id: Integer; const depth: Integer; const what: WideString): kt_folder_contents; stdcall;
  484 + function create_folder(const session_id: WideString; const folder_id: Integer; const folder_name: WideString): kt_folder_detail; stdcall;
  485 + function delete_folder(const session_id: WideString; const folder_id: Integer; const reason: WideString): kt_response; stdcall;
  486 + function rename_folder(const session_id: WideString; const folder_id: Integer; const newname: WideString): kt_response; stdcall;
  487 + function get_document_links(const session_id: WideString; const document_id: Integer): kt_linked_document_response; stdcall;
  488 + function link_documents(const session_id: WideString; const parent_document_id: Integer; const child_document_id: Integer; const type_: WideString): kt_response; stdcall;
  489 + function unlink_documents(const session_id: WideString; const parent_document_id: Integer; const child_document_id: Integer): kt_response; stdcall;
  490 + function copy_folder(const session_id: WideString; const source_id: Integer; const target_id: Integer; const reason: WideString): kt_response; stdcall;
  491 + function move_folder(const session_id: WideString; const source_id: Integer; const target_id: Integer; const reason: WideString): kt_response; stdcall;
  492 + function get_document_detail(const session_id: WideString; const document_id: Integer): kt_document_detail; stdcall;
  493 + function checkin_document(const session_id: WideString; const document_id: Integer; const filename: WideString; const reason: WideString; const tempfilename: WideString; const major_update: Boolean): kt_response; stdcall;
  494 + function checkin_small_document(const session_id: WideString; const document_id: Integer; const filename: WideString; const reason: WideString; const base64: WideString; const major_update: Boolean): kt_response; stdcall;
  495 + function checkin_base64_document(const session_id: WideString; const document_id: Integer; const filename: WideString; const reason: WideString; const base64: WideString; const major_update: Boolean): kt_response; stdcall;
  496 + function add_document(const session_id: WideString; const folder_id: Integer; const title: WideString; const filename: WideString; const documentype: WideString; const tempfilename: WideString): kt_document_detail; stdcall;
  497 + function add_small_document(const session_id: WideString; const folder_id: Integer; const title: WideString; const filename: WideString; const documentype: WideString; const base64: WideString): kt_document_detail; stdcall;
  498 + function add_base64_document(const session_id: WideString; const folder_id: Integer; const title: WideString; const filename: WideString; const documentype: WideString; const base64: WideString): kt_document_detail; stdcall;
  499 + function get_document_detail_by_name(const session_id: WideString; const document_name: WideString; const what: WideString): kt_document_detail; stdcall;
  500 + function checkout_document(const session_id: WideString; const document_id: Integer; const reason: WideString): kt_response; stdcall;
  501 + function checkout_small_document(const session_id: WideString; const document_id: Integer; const reason: WideString; const download: Boolean): kt_response; stdcall;
  502 + function checkout_base64_document(const session_id: WideString; const document_id: Integer; const reason: WideString; const download: Boolean): kt_response; stdcall;
  503 + function undo_document_checkout(const session_id: WideString; const document_id: Integer; const reason: WideString): kt_response; stdcall;
  504 + function download_document(const session_id: WideString; const document_id: Integer): kt_response; stdcall;
  505 + function download_small_document(const session_id: WideString; const document_id: Integer): kt_response; stdcall;
  506 + function download_base64_document(const session_id: WideString; const document_id: Integer): kt_response; stdcall;
  507 + function delete_document(const session_id: WideString; const document_id: Integer; const reason: WideString): kt_response; stdcall;
  508 + function change_document_owner(const session_id: WideString; const document_id: Integer; const username: WideString; const reason: WideString): kt_response; stdcall;
  509 + function copy_document(const session_id: WideString; const document_id: Integer; const folder_id: Integer; const reason: WideString; const newtitle: WideString; const newfilename: WideString): kt_response; stdcall;
  510 + function move_document(const session_id: WideString; const document_id: Integer; const folder_id: Integer; const reason: WideString; const newtitle: WideString; const newfilename: WideString): kt_response; stdcall;
  511 + function rename_document_title(const session_id: WideString; const document_id: Integer; const newtitle: WideString): kt_response; stdcall;
  512 + function rename_document_filename(const session_id: WideString; const document_id: Integer; const newfilename: WideString): kt_response; stdcall;
  513 + function change_document_type(const session_id: WideString; const document_id: Integer; const documenttype: WideString): kt_response; stdcall;
  514 + function start_document_workflow(const session_id: WideString; const document_id: Integer; const workflow: WideString): kt_response; stdcall;
  515 + function delete_document_workflow(const session_id: WideString; const document_id: Integer): kt_response; stdcall;
  516 + function perform_document_workflow_transition(const session_id: WideString; const document_id: Integer; const transition: WideString; const reason: WideString): kt_response; stdcall;
  517 + function get_document_metadata(const session_id: WideString; const document_id: Integer): kt_metadata_response; stdcall;
  518 + function get_document_type_metadata(const session_id: WideString; const document_type: WideString): kt_metadata_response; stdcall;
  519 + function update_document_metadata(const session_id: WideString; const document_id: Integer; const metadata: kt_metadata_fieldsets): kt_response; stdcall;
  520 + function get_document_workflow_transitions(const session_id: WideString; const document_id: Integer): kt_document_transitions_response; stdcall;
  521 + function get_document_workflow_state(const session_id: WideString; const document_id: Integer): kt_response; stdcall;
  522 + function get_document_transaction_history(const session_id: WideString; const document_id: Integer): kt_document_transaction_history_response; stdcall;
  523 + function get_document_version_history(const session_id: WideString; const document_id: Integer): kt_document_version_history_response; stdcall;
  524 + function get_document_types(const session_id: WideString): kt_document_types_response; stdcall;
  525 + function get_document_link_types(const session_id: WideString): kt_document_types_response; stdcall;
  526 + end;
  527 +
  528 +function GetKnowledgeTreePort(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): KnowledgeTreePort;
  529 +
  530 +
  531 +implementation
  532 +
  533 +function GetKnowledgeTreePort(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): KnowledgeTreePort;
  534 +const
  535 + defWSDL = 'http://ktdms.trunk/ktwebservice/webservice.php?wsdl';
  536 + defURL = 'http://ktdms.trunk/ktwebservice/webservice.php';
  537 + defSvc = 'KnowledgeTreeService';
  538 + defPrt = 'KnowledgeTreePort';
  539 +var
  540 + RIO: THTTPRIO;
  541 +begin
  542 + Result := nil;
  543 + if (Addr = '') then
  544 + begin
  545 + if UseWSDL then
  546 + Addr := defWSDL
  547 + else
  548 + Addr := defURL;
  549 + end;
  550 + if HTTPRIO = nil then
  551 + RIO := THTTPRIO.Create(nil)
  552 + else
  553 + RIO := HTTPRIO;
  554 + try
  555 + Result := (RIO as KnowledgeTreePort);
  556 + if UseWSDL then
  557 + begin
  558 + RIO.WSDLLocation := Addr;
  559 + RIO.Service := defSvc;
  560 + RIO.Port := defPrt;
  561 + end else
  562 + RIO.URL := Addr;
  563 + finally
  564 + if (Result = nil) and (HTTPRIO = nil) then
  565 + RIO.Free;
  566 + end;
  567 +end;
  568 +
  569 +
  570 +destructor kt_folder_item.Destroy;
  571 +var
  572 + I: Integer;
  573 +begin
  574 + for I := 0 to Length(Fitems)-1 do
  575 + if Assigned(Fitems[I]) then
  576 + Fitems[I].Free;
  577 + SetLength(Fitems, 0);
  578 + inherited Destroy;
  579 +end;
  580 +
  581 +destructor kt_folder_contents.Destroy;
  582 +var
  583 + I: Integer;
  584 +begin
  585 + for I := 0 to Length(Fitems)-1 do
  586 + if Assigned(Fitems[I]) then
  587 + Fitems[I].Free;
  588 + SetLength(Fitems, 0);
  589 + inherited Destroy;
  590 +end;
  591 +
  592 +destructor kt_metadata_field.Destroy;
  593 +var
  594 + I: Integer;
  595 +begin
  596 + for I := 0 to Length(Fselection)-1 do
  597 + if Assigned(Fselection[I]) then
  598 + Fselection[I].Free;
  599 + SetLength(Fselection, 0);
  600 + inherited Destroy;
  601 +end;
  602 +
  603 +destructor kt_metadata_fieldset.Destroy;
  604 +var
  605 + I: Integer;
  606 +begin
  607 + for I := 0 to Length(Ffields)-1 do
  608 + if Assigned(Ffields[I]) then
  609 + Ffields[I].Free;
  610 + SetLength(Ffields, 0);
  611 + inherited Destroy;
  612 +end;
  613 +
  614 +destructor kt_metadata_response.Destroy;
  615 +var
  616 + I: Integer;
  617 +begin
  618 + for I := 0 to Length(Fmetadata)-1 do
  619 + if Assigned(Fmetadata[I]) then
  620 + Fmetadata[I].Free;
  621 + SetLength(Fmetadata, 0);
  622 + inherited Destroy;
  623 +end;
  624 +
  625 +destructor kt_linked_document_response.Destroy;
  626 +var
  627 + I: Integer;
  628 +begin
  629 + for I := 0 to Length(Flinks)-1 do
  630 + if Assigned(Flinks[I]) then
  631 + Flinks[I].Free;
  632 + SetLength(Flinks, 0);
  633 + inherited Destroy;
  634 +end;
  635 +
  636 +destructor kt_document_transaction_history_response.Destroy;
  637 +var
  638 + I: Integer;
  639 +begin
  640 + for I := 0 to Length(Fhistory)-1 do
  641 + if Assigned(Fhistory[I]) then
  642 + Fhistory[I].Free;
  643 + SetLength(Fhistory, 0);
  644 + inherited Destroy;
  645 +end;
  646 +
  647 +destructor kt_document_version_history_response.Destroy;
  648 +var
  649 + I: Integer;
  650 +begin
  651 + for I := 0 to Length(Fhistory)-1 do
  652 + if Assigned(Fhistory[I]) then
  653 + Fhistory[I].Free;
  654 + SetLength(Fhistory, 0);
  655 + inherited Destroy;
  656 +end;
  657 +
  658 +initialization
  659 + InvRegistry.RegisterInterface(TypeInfo(KnowledgeTreePort), 'http://schemas.xmlsoap.org/soap/envelope/', '');
  660 + InvRegistry.RegisterDefaultSOAPAction(TypeInfo(KnowledgeTreePort), 'http://schemas.xmlsoap.org/soap/envelope/#KTWebService#%operationName%');
  661 + InvRegistry.RegisterExternalParamName(TypeInfo(KnowledgeTreePort), 'link_documents', 'type_', 'type');
  662 + RemClassRegistry.RegisterXSClass(kt_response, 'urn:KnowledgeTree', 'kt_response');
  663 + RemClassRegistry.RegisterExternalPropName(TypeInfo(kt_response), 'message_', 'message');
  664 + RemClassRegistry.RegisterXSClass(kt_folder_detail, 'urn:KnowledgeTree', 'kt_folder_detail');
  665 + RemClassRegistry.RegisterExternalPropName(TypeInfo(kt_folder_detail), 'message_', 'message');
  666 + RemClassRegistry.RegisterXSInfo(TypeInfo(kt_folder_items), 'urn:KnowledgeTree', 'kt_folder_items');
  667 + RemClassRegistry.RegisterXSClass(kt_folder_item, 'urn:KnowledgeTree', 'kt_folder_item');
  668 + RemClassRegistry.RegisterXSClass(kt_folder_contents, 'urn:KnowledgeTree', 'kt_folder_contents');
  669 + RemClassRegistry.RegisterExternalPropName(TypeInfo(kt_folder_contents), 'message_', 'message');
  670 + RemClassRegistry.RegisterXSClass(kt_document_detail, 'urn:KnowledgeTree', 'kt_document_detail');
  671 + RemClassRegistry.RegisterExternalPropName(TypeInfo(kt_document_detail), 'message_', 'message');
  672 + RemClassRegistry.RegisterXSClass(kt_metadata_selection_item, 'urn:KnowledgeTree', 'kt_metadata_selection_item');
  673 + RemClassRegistry.RegisterExternalPropName(TypeInfo(kt_metadata_selection_item), 'name_', 'name');
  674 + RemClassRegistry.RegisterXSInfo(TypeInfo(kt_metadata_selection), 'urn:KnowledgeTree', 'kt_metadata_selection');
  675 + RemClassRegistry.RegisterXSClass(kt_metadata_field, 'urn:KnowledgeTree', 'kt_metadata_field');
  676 + RemClassRegistry.RegisterExternalPropName(TypeInfo(kt_metadata_field), 'name_', 'name');
  677 + RemClassRegistry.RegisterXSInfo(TypeInfo(kt_metadata_fields), 'urn:KnowledgeTree', 'kt_metadata_fields');
  678 + RemClassRegistry.RegisterXSClass(kt_metadata_fieldset, 'urn:KnowledgeTree', 'kt_metadata_fieldset');
  679 + RemClassRegistry.RegisterXSInfo(TypeInfo(kt_metadata_fieldsets), 'urn:KnowledgeTree', 'kt_metadata_fieldsets');
  680 + RemClassRegistry.RegisterXSClass(kt_metadata_response, 'urn:KnowledgeTree', 'kt_metadata_response');
  681 + RemClassRegistry.RegisterExternalPropName(TypeInfo(kt_metadata_response), 'message_', 'message');
  682 + RemClassRegistry.RegisterXSInfo(TypeInfo(kt_document_transitions), 'urn:KnowledgeTree', 'kt_document_transitions');
  683 + RemClassRegistry.RegisterXSClass(kt_document_transitions_response, 'urn:KnowledgeTree', 'kt_document_transitions_response');
  684 + RemClassRegistry.RegisterExternalPropName(TypeInfo(kt_document_transitions_response), 'message_', 'message');
  685 + RemClassRegistry.RegisterXSClass(kt_document_transaction_history_item, 'urn:KnowledgeTree', 'kt_document_transaction_history_item');
  686 + RemClassRegistry.RegisterXSClass(kt_linked_document, 'urn:KnowledgeTree', 'kt_linked_document');
  687 + RemClassRegistry.RegisterXSInfo(TypeInfo(kt_linked_documents), 'urn:KnowledgeTree', 'kt_linked_documents');
  688 + RemClassRegistry.RegisterXSClass(kt_linked_document_response, 'urn:KnowledgeTree', 'kt_linked_document_response');
  689 + RemClassRegistry.RegisterExternalPropName(TypeInfo(kt_linked_document_response), 'message_', 'message');
  690 + RemClassRegistry.RegisterXSInfo(TypeInfo(kt_document_transaction_history), 'urn:KnowledgeTree', 'kt_document_transaction_history');
  691 + RemClassRegistry.RegisterXSClass(kt_document_transaction_history_response, 'urn:KnowledgeTree', 'kt_document_transaction_history_response');
  692 + RemClassRegistry.RegisterExternalPropName(TypeInfo(kt_document_transaction_history_response), 'message_', 'message');
  693 + RemClassRegistry.RegisterXSClass(kt_document_version_history_item, 'urn:KnowledgeTree', 'kt_document_version_history_item');
  694 + RemClassRegistry.RegisterXSInfo(TypeInfo(kt_document_version_history), 'urn:KnowledgeTree', 'kt_document_version_history');
  695 + RemClassRegistry.RegisterXSClass(kt_document_version_history_response, 'urn:KnowledgeTree', 'kt_document_version_history_response');
  696 + RemClassRegistry.RegisterExternalPropName(TypeInfo(kt_document_version_history_response), 'message_', 'message');
  697 + RemClassRegistry.RegisterXSInfo(TypeInfo(kt_document_types_array), 'urn:KnowledgeTree', 'kt_document_types_array');
  698 + RemClassRegistry.RegisterXSClass(kt_document_types_response, 'urn:KnowledgeTree', 'kt_document_types_response');
  699 + RemClassRegistry.RegisterExternalPropName(TypeInfo(kt_document_types_response), 'message_', 'message');
  700 +
  701 +end.
... ...
lib/documentmanagement/documentutil.inc.php
... ... @@ -898,7 +898,6 @@ class KTDocumentUtil {
898 898 $sReason = '';
899 899 }
900 900  
901   -
902 901 $oDocumentTransaction = new DocumentTransaction($oDocument, sprintf(_kt("Copied to folder \"%s\". %s"), $oDestinationFolder->getName(), $sReason), 'ktcore.transactions.copy');
903 902 $oDocumentTransaction->create();
904 903  
... ... @@ -906,6 +905,24 @@ class KTDocumentUtil {
906 905 $oDocumentTransaction = new DocumentTransaction($oNewDocument, sprintf(_kt("Copied from original in folder \"%s\". %s"), $oSrcFolder->getName(), $sReason), 'ktcore.transactions.copy');
907 906 $oDocumentTransaction->create();
908 907  
  908 +
  909 + $oKTTriggerRegistry = KTTriggerRegistry::getSingleton();
  910 + $aTriggers = $oKTTriggerRegistry->getTriggers('copyDocument', 'postValidate');
  911 + foreach ($aTriggers as $aTrigger) {
  912 + $sTrigger = $aTrigger[0];
  913 + $oTrigger = new $sTrigger;
  914 + $aInfo = array(
  915 + 'document' => $oNewDocument,
  916 + 'old_folder' => $oSrcFolder,
  917 + 'new_folder' => $oDestinationFolder,
  918 + );
  919 + $oTrigger->setInfo($aInfo);
  920 + $ret = $oTrigger->postValidate();
  921 + if (PEAR::isError($ret)) {
  922 + return $ret;
  923 + }
  924 + }
  925 +
909 926 return $oNewDocument;
910 927 }
911 928  
... ... @@ -1013,15 +1030,15 @@ class KTDocumentUtil {
1013 1030  
1014 1031 return KTPermissionUtil::updatePermissionLookup($oDocument);
1015 1032 }
1016   -
  1033 +
1017 1034 /**
1018 1035 * Delete a selected version of the document.
1019 1036 */
1020 1037 function deleteVersion($oDocument, $iVersionID, $sReason){
1021   -
  1038 +
1022 1039 $oDocument =& KTUtil::getObject('Document', $oDocument);
1023 1040 $oVersion =& KTDocumentMetadataVersion::get($iVersionID);
1024   -
  1041 +
1025 1042 $oStorageManager =& KTStorageManagerUtil::getSingleton();
1026 1043  
1027 1044 global $default;
... ... @@ -1037,17 +1054,17 @@ class KTDocumentUtil {
1037 1054 if (PEAR::isError($oVersion) || ($oVersion == false)) {
1038 1055 return PEAR::raiseError(_kt('Invalid document version object.'));
1039 1056 }
1040   -
  1057 +
1041 1058 $iContentId = $oVersion->getContentVersionId();
1042 1059 $oContentVersion = KTDocumentContentVersion::get($iContentId);
1043   -
  1060 +
1044 1061 if (PEAR::isError($oContentVersion) || ($oContentVersion == false)) {
1045 1062 DBUtil::rollback();
1046 1063 return PEAR::raiseError(_kt('Invalid document content version object.'));
1047 1064 }
1048 1065  
1049 1066 DBUtil::startTransaction();
1050   -
  1067 +
1051 1068 // now delete the document version
1052 1069 $res = $oStorageManager->deleteVersion($oVersion);
1053 1070 if (PEAR::isError($res) || ($res == false)) {
... ... @@ -1064,11 +1081,11 @@ class KTDocumentUtil {
1064 1081  
1065 1082 return PEAR::raiseError(_kt('There was a problem deleting the document from storage.'));
1066 1083 }
1067   -
  1084 +
1068 1085 // change status for the metadata version
1069 1086 $oVersion->setStatusId(VERSION_DELETED);
1070 1087 $oVersion->update();
1071   -
  1088 +
1072 1089 // set the storage path to empty
1073 1090 // $oContentVersion->setStoragePath('');
1074 1091  
... ...
lib/upgrades/Ini.inc.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * $Id:$
  4 + *
  5 + * The contents of this file are subject to the KnowledgeTree Public
  6 + * License Version 1.1.2 ("License"); You may not use this file except in
  7 + * compliance with the License. You may obtain a copy of the License at
  8 + * http://www.knowledgetree.com/KPL
  9 + *
  10 + * Software distributed under the License is distributed on an "AS IS"
  11 + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
  12 + * See the License for the specific language governing rights and
  13 + * limitations under the License.
  14 + *
  15 + * All copies of the Covered Code must include on each user interface screen:
  16 + * (i) the "Powered by KnowledgeTree" logo and
  17 + * (ii) the KnowledgeTree copyright notice
  18 + * in the same form as they appear in the distribution. See the License for
  19 + * requirements.
  20 + *
  21 + * The Original Code is: KnowledgeTree Open Source
  22 + *
  23 + * The Initial Developer of the Original Code is The Jam Warehouse Software
  24 + * (Pty) Ltd, trading as KnowledgeTree.
  25 + * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright
  26 + * (C) 2007 The Jam Warehouse Software (Pty) Ltd;
  27 + * All Rights Reserved.
  28 + * Contributor( s): ______________________________________
  29 + *
  30 + */
  31 +
  32 +/*
  33 + * TODO: Add more functionality when needed like delete and modify
  34 + */
  35 +
  36 +class Ini {
  37 +
  38 + var $cleanArray = array();
  39 + var $iniFile = '';
  40 + var $lineNum = 0;
  41 + var $exists = '';
  42 +
  43 + function Ini($iniFile = '../../../config.ini') {
  44 + $this->iniFile = $iniFile;
  45 + $this->read($iniFile);
  46 + }
  47 +
  48 + function read($iniFile) {
  49 +
  50 + $iniArray = file($iniFile);
  51 + $section = '';
  52 + foreach($iniArray as $iniLine) {
  53 + $this->lineNum++;
  54 + $iniLine = trim($iniLine);
  55 + $firstChar = substr($iniLine, 0, 1);
  56 + if($firstChar == ';') {
  57 + if($section == ''){
  58 + $this->cleanArray['_comment_'.$this->lineNum]=$iniLine;
  59 + }else {
  60 + $this->cleanArray[$section]['_comment_'.$this->lineNum]=$iniLine;
  61 + }
  62 + continue;
  63 + }
  64 + if($iniLine == '') {
  65 + if($section == ''){
  66 + $this->cleanArray['_blankline_'.$this->lineNum]='';
  67 + }else {
  68 + $this->cleanArray[$section]['_blankline_'.$this->lineNum]='';
  69 + }
  70 + continue;
  71 + }
  72 +
  73 + if ($firstChar == '[' && substr($iniLine, -1, 1) == ']') {
  74 + $section = substr($iniLine, 1, -1);
  75 + $this->sections[] = $section;
  76 + } else {
  77 + $equalsPos = strpos($iniLine, '=');
  78 + if ($equalsPos > 0 && $equalsPos != sizeof($iniLine)) {
  79 + $key = trim(substr($iniLine, 0, $equalsPos));
  80 + $value = trim(substr($iniLine, $equalsPos+1));
  81 + if (substr($value, 1, 1) == '"' && substr( $value, -1, 1) == '"') {
  82 + $value = substr($value, 1, -1);
  83 + }
  84 + $this->cleanArray[$section][$key] = stripcslashes($value);
  85 + } else {
  86 + $this->cleanArray[$section][trim($iniLine)]='';
  87 + }
  88 + }
  89 + }
  90 + return $this->cleanArray;
  91 + }
  92 +
  93 + function write($iniFile = "") {
  94 +
  95 + if(empty($iniFile)) {
  96 + $iniFile = $this->iniFile;
  97 + }
  98 + $fileHandle = fopen($iniFile, 'wb');
  99 + foreach ($this->cleanArray as $section => $items) {
  100 + if (substr($section, 0, strlen('_blankline_')) === '_blankline_' ) {
  101 + fwrite ($fileHandle, "\r\n");
  102 + continue;
  103 + }
  104 + if (substr($section, 0, strlen('_comment_')) === '_comment_' ) {
  105 + fwrite ($fileHandle, "$items\r\n");
  106 + continue;
  107 + }
  108 + fwrite ($fileHandle, "[".$section."]\r\n");
  109 + foreach ($items as $key => $value) {
  110 + if (substr($key, 0, strlen('_blankline_')) === '_blankline_' ) {
  111 + fwrite ($fileHandle, "\r\n");
  112 + continue;
  113 + }
  114 + if (substr($key, 0, strlen('_comment_')) === '_comment_' ) {
  115 + fwrite ($fileHandle, "$value\r\n");
  116 + continue;
  117 + }
  118 +
  119 + $value = addcslashes($value,'');
  120 + //fwrite ($fileHandle, $key.' = "'.$value."\"\r\n");
  121 + fwrite ($fileHandle, $key.' = '.$value."\r\n");
  122 + }
  123 + }
  124 + fclose($fileHandle);
  125 + }
  126 +
  127 + function itemExists($checkSection, $checkItem) {
  128 +
  129 + $this->exists = '';
  130 + foreach($this->cleanArray as $section => $items) {
  131 + if($section == $checkSection) {
  132 + $this->exists = 'section';
  133 + foreach ($items as $key => $value) {
  134 + if($key == $checkItem) {
  135 + return true;
  136 + }
  137 + }
  138 + }
  139 + }
  140 + return false;
  141 + }
  142 +
  143 + function addItem($addSection, $addItem, $value, $itemComment = '', $sectionComment = '') {
  144 +
  145 + if($this->itemExists($addSection, $addItem)) return false;
  146 +
  147 + if($this->exists != 'section') {
  148 + $this->cleanArray['_blankline_'.$this->lineNum++]='';
  149 + if(!empty($sectionComment)) $this->cleanArray['_comment_'.$this->lineNum++] = '; '.$sectionComment;
  150 + }
  151 + if(!empty($itemComment)) {
  152 + $this->cleanArray[$addSection]['_comment_'.$this->lineNum++] = '; '.$itemComment;
  153 + }
  154 + $this->cleanArray[$addSection][$addItem] = stripcslashes($value);
  155 + return true;
  156 + }
  157 +
  158 +}
  159 +/*
  160 +// USAGE EXAMPLE
  161 +
  162 +if(file_exists('../../../config.ini')) {
  163 +
  164 + $ini = new Ini();
  165 + $ini->addItem('Section1', 'NewItem1', 'Some Text1', 'Item1 Comment', 'Section1 Comment');
  166 + $ini->addItem('Section1', 'NewItem1.2', 'Some Text1.2', 'Item1.2 Comment');
  167 + $ini->addItem('Section1', 'NewItem1.3', 'Some Text1.3', 'Item1.3 Comment');
  168 + $ini->addItem('Section1', 'NewItem1.4', 'Some Text1.4', 'Item1.4 Comment');
  169 + $ini->addItem('Section2', 'NewItem2', 'Some Text2', 'Item2 Comment');
  170 + $ini->addItem('Section2', 'NewItem2.1', 'Some Text2.1');
  171 + $ini->addItem('Section3', 'NewItem3', 'Some Text3', 'Item3 Comment', 'Section3 Comment');
  172 + $ini->addItem('Section4', 'NewItem4', 'Some Text4', 'Item4 Comment');
  173 + $ini->write();
  174 +
  175 +}
  176 +*/
  177 +?>
... ...
plugins/generalmetadata/GeneralMetadataDashlet.php deleted
1   -<?php
2   -
3   -/*
4   - * The contents of this file are subject to the KnowledgeTree Public
5   - * License Version 1.1.2 ("License"); You may not use this file except in
6   - * compliance with the License. You may obtain a copy of the License at
7   - * http://www.knowledgetree.com/KPL
8   - *
9   - * Software distributed under the License is distributed on an "AS IS"
10   - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
11   - * See the License for the specific language governing rights and
12   - * limitations under the License.
13   - *
14   - * All copies of the Covered Code must include on each user interface screen:
15   - * (i) the "Powered by KnowledgeTree" logo and
16   - * (ii) the KnowledgeTree copyright notice
17   - * in the same form as they appear in the distribution. See the License for
18   - * requirements.
19   - *
20   - * The Original Code is: KnowledgeTree Open Source
21   - *
22   - * The Initial Developer of the Original Code is The Jam Warehouse Software
23   - * (Pty) Ltd, trading as KnowledgeTree.
24   - * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright
25   - * (C) 2007 The Jam Warehouse Software (Pty) Ltd;
26   - * All Rights Reserved.
27   - * Contributor( s): ______________________________________
28   - *
29   - */
30   -
31   -
32   -require_once(KT_LIB_DIR . '/browse/browseutil.inc.php');
33   -require_once(KT_LIB_DIR . '/plugins/pluginregistry.inc.php');
34   -require_once(KT_LIB_DIR . '/plugins/plugin.inc.php');
35   -
36   -class GeneralMetadataDashlet extends KTBaseDashlet {
37   - var $oUser;
38   - var $sClass = 'ktBlock';
39   -
40   - /**
41   - * Constructor method
42   - *
43   - * @return GeneralMetadataDashlet
44   - */
45   - function GeneralMetadataDashlet(){
46   - $this->sTitle = _kt('General Metadata Search');
47   - }
48   -
49   - /**
50   - * Check to see if user is active
51   - *
52   - * @param object $oUser
53   - * @return boolean
54   - */
55   - function is_active($oUser) {
56   - $this->oUser = $oUser;
57   - return true;
58   - }
59   -
60   - /**
61   - * Render function for template
62   - *
63   - * @return unknown
64   - */
65   - function render() {
66   - $oTemplating =& KTTemplating::getSingleton();
67   - $oTemplate = $oTemplating->loadTemplate('GeneralMetadata/dashlet');
68   -
69   - $oRegistry =& KTPluginRegistry::getSingleton();
70   - $oPlugin =& $oRegistry->getPlugin('ktcore.generalmetadata.plugin');
71   - $url = $oPlugin->getPagePath('GeneralMetadataPage');
72   -
73   - $aTemplateData = array(
74   - 'context' => $this,
75   - 'url' => $url,
76   - );
77   - return $oTemplate->render($aTemplateData);
78   - }
79   -}
80   -?>
plugins/generalmetadata/GeneralMetadataPage.php deleted
1   -<?php
2   -
3   -/*
4   - * The contents of this file are subject to the KnowledgeTree Public
5   - * License Version 1.1.2 ("License"); You may not use this file except in
6   - * compliance with the License. You may obtain a copy of the License at
7   - * http://www.knowledgetree.com/KPL
8   - *
9   - * Software distributed under the License is distributed on an "AS IS"
10   - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
11   - * See the License for the specific language governing rights and
12   - * limitations under the License.
13   - *
14   - * All copies of the Covered Code must include on each user interface screen:
15   - * (i) the "Powered by KnowledgeTree" logo and
16   - * (ii) the KnowledgeTree copyright notice
17   - * in the same form as they appear in the distribution. See the License for
18   - * requirements.
19   - *
20   - * The Original Code is: KnowledgeTree Open Source
21   - *
22   - * The Initial Developer of the Original Code is The Jam Warehouse Software
23   - * (Pty) Ltd, trading as KnowledgeTree.
24   - * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright
25   - * (C) 2007 The Jam Warehouse Software (Pty) Ltd;
26   - * All Rights Reserved.
27   - * Contributor( s): ______________________________________
28   - *
29   - */
30   -
31   -require_once(KT_LIB_DIR . '/plugins/plugin.inc.php');
32   -require_once(KT_LIB_DIR . '/plugins/pluginregistry.inc.php');
33   -require_once(KT_LIB_DIR . "/templating/templating.inc.php");
34   -require_once(KT_LIB_DIR . "/database/dbutil.inc");
35   -require_once(KT_LIB_DIR . "/util/ktutil.inc");
36   -require_once(KT_LIB_DIR . "/dispatcher.inc.php");
37   -require_once(KT_LIB_DIR . "/browse/Criteria.inc");
38   -require_once(KT_LIB_DIR . "/search/savedsearch.inc.php");
39   -require_once(KT_LIB_DIR . "/search/searchutil.inc.php");
40   -
41   -require_once(KT_LIB_DIR . "/browse/DocumentCollection.inc.php");
42   -require_once(KT_LIB_DIR . "/browse/BrowseColumns.inc.php");
43   -require_once(KT_LIB_DIR . "/browse/PartialQuery.inc.php");
44   -
45   -require_once(KT_LIB_DIR . '/widgets/fieldWidgets.php');
46   -require_once(KT_LIB_DIR . '/actions/bulkaction.php');
47   -
48   -class GeneralMetadataPage extends KTStandardDispatcher {
49   -
50   - function do_main() {
51   - $searchable_text = KTUtil::arrayGet($_POST, "fSearchableText");
52   -
53   - // set breadcrumbs
54   - $this->aBreadcrumbs[] = array('url' => 'dashboard.php', 'name' => _kt('Dashboard'));
55   - $this->aBreadcrumbs[] = array('name' => _kt('General Metadata Search'));
56   -
57   - $sTitle = _kt('Search Results');
58   - $this->oPage->setBreadcrumbDetails($sTitle);
59   -
60   -
61   - $aCriteriaSet = array(
62   - 'join'=>'AND',
63   - 'subgroup'=>array(
64   - 0=>array(
65   - 'join'=>'AND',
66   - 'values'=>array(
67   - 1=>array(
68   - 'data'=>array(
69   - 'ktcore.criteria.generalmetadata'=>$searchable_text,
70   - 'ktcore.criteria.generalmetadata_not'=>0
71   - ),
72   - 'type'=>'ktcore.criteria.generalmetadata'
73   - )
74   - )
75   - )
76   - )
77   - );
78   -
79   -
80   - $this->browseType = "Folder";
81   - $sSearch = md5(serialize($aCriteriaSet));
82   - $_SESSION['boolean_search'][$sSearch] = $aCriteriaSet;
83   -
84   - $collection = new AdvancedCollection;
85   - $oColumnRegistry = KTColumnRegistry::getSingleton();
86   - $aColumns = $oColumnRegistry->getColumnsForView('ktcore.views.search');
87   - $collection->addColumns($aColumns);
88   -
89   - // set a view option
90   - $aTitleOptions = array(
91   - 'documenturl' => $GLOBALS['KTRootUrl'] . '/view.php',
92   - );
93   - $collection->setColumnOptions('ktcore.columns.title', $aTitleOptions);
94   - $collection->setColumnOptions('ktcore.columns.selection', array(
95   - 'rangename' => 'selection',
96   - 'show_folders' => true,
97   - 'show_documents' => true,
98   - ));
99   -
100   - $aOptions = $collection->getEnvironOptions(); // extract data from the environment
101   -
102   - $aOptions['return_url'] = KTUtil::addQueryStringSelf("action=performSearch&boolean_search_id=" . urlencode($sSearch));
103   - $aOptions['empty_message'] = _kt("No documents or folders match this query.");
104   - $aOptions['is_browse'] = true;
105   -
106   - $collection->setOptions($aOptions);
107   - $collection->setQueryObject(new BooleanSearchQuery($aCriteriaSet));
108   -
109   - $oTemplating =& KTTemplating::getSingleton();
110   - $oTemplate = $oTemplating->loadTemplate("kt3/browse");
111   - $aTemplateData = array(
112   - "context" => $this,
113   - "collection" => $collection,
114   - "custom_title" => $sTitle,
115   - "params" => $aParams,
116   - "joins" => $aJoins,
117   - 'isEditable' => true,
118   - "boolean_search" => $sSearch,
119   - 'bulkactions' => KTBulkActionUtil::getAllBulkActions(),
120   - 'browseutil' => new KTBrowseUtil(),
121   - 'returnaction' => 'booleanSearch',
122   - 'returndata' => $sSearch,
123   -
124   - );
125   - return $oTemplate->render($aTemplateData);
126   - }
127   -}
128   -?>
129 0 \ No newline at end of file
plugins/generalmetadata/GeneralMetadataPlugin.php deleted
1   -<?php
2   -
3   -/*
4   - * The contents of this file are subject to the KnowledgeTree Public
5   - * License Version 1.1.2 ("License"); You may not use this file except in
6   - * compliance with the License. You may obtain a copy of the License at
7   - * http://www.knowledgetree.com/KPL
8   - *
9   - * Software distributed under the License is distributed on an "AS IS"
10   - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
11   - * See the License for the specific language governing rights and
12   - * limitations under the License.
13   - *
14   - * All copies of the Covered Code must include on each user interface screen:
15   - * (i) the "Powered by KnowledgeTree" logo and
16   - * (ii) the KnowledgeTree copyright notice
17   - * in the same form as they appear in the distribution. See the License for
18   - * requirements.
19   - *
20   - * The Original Code is: KnowledgeTree Open Source
21   - *
22   - * The Initial Developer of the Original Code is The Jam Warehouse Software
23   - * (Pty) Ltd, trading as KnowledgeTree.
24   - * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright
25   - * (C) 2007 The Jam Warehouse Software (Pty) Ltd;
26   - * All Rights Reserved.
27   - * Contributor( s): ______________________________________
28   - *
29   - */
30   -
31   -require_once(KT_LIB_DIR . '/plugins/plugin.inc.php');
32   -require_once(KT_LIB_DIR . '/plugins/pluginregistry.inc.php');
33   -require_once('GeneralMetadataPage.php');
34   -require_once(KT_LIB_DIR . '/templating/templating.inc.php');
35   -
36   - /**
37   - * Tag Cloud Plugin class
38   - *
39   - */
40   - class GeneralMetadataPlugin extends KTPlugin{
41   -
42   - var $sNamespace = 'ktcore.generalmetadata.plugin';
43   -
44   - /**
45   - * Constructor method for plugin
46   - *
47   - * @param string $sFilename
48   - * @return GeneralMetadataPlugin
49   - */
50   - function GeneralMetadataPlugin($sFilename = null) {
51   - $res = parent::KTPlugin($sFilename);
52   - $this->sFriendlyName = _kt('General Metadata Search Plugin');
53   - return $res;
54   - }
55   -
56   - /**
57   - * Setup function for plugin
58   - *
59   - */
60   - function setup() {
61   - // Register plugin components
62   - $this->registerCriterion('GeneralMetadataCriterion', 'ktcore.criteria.generalmetadata', KT_LIB_DIR . '/browse/Criteria.inc');
63   - $this->registerDashlet('GeneralMetadataDashlet', 'ktcore.generalmetadata.dashlet', 'GeneralMetadataDashlet.php');
64   - $this->registerPage('GeneralMetadataPage', 'GeneralMetadataPage', __FILE__);
65   -
66   - $oTemplating =& KTTemplating::getSingleton();
67   - $oTemplating->addLocation('General Metadata Search', '/plugins/generalmetadata/templates');
68   - }
69   - }
70   -$oPluginRegistry =& KTPluginRegistry::getSingleton();
71   -$oPluginRegistry->registerPlugin('GeneralMetadataPlugin', 'ktcore.generalmetadata.plugin', __FILE__);
72 0 \ No newline at end of file
plugins/generalmetadata/templates/GeneralMetadata/dashlet.smarty deleted
1   -<form action="{$url}" method="POST">
2   -<input onclick="this.focus()" type="text" name="fSearchableText" id="dashlet-search-text"
3   -size="15" /><input type="submit" value="{i18n}search{/i18n}"
4   -class="searchbutton frontpage" />
5   -</form>
6   -{if (!empty($saved_searches))}
7   -<hr />
8   -<h3>{i18n}Saved Searches{/i18n}</h3>
9   -{foreach item=oSearch from=$saved_searches}
10   -<span class="descriptiveText">{i18n}Saved Search{/i18n}: </span><a
11   -href="{"booleanSearch"|generateControllerUrl}&qs[action]=performSearch&qs[fSavedSearchId]={$oSearch->getId()}">{$oSearch->getName()}</a><br />
12   -{/foreach}
13   -
14   -
15   -{/if}
16 0 \ No newline at end of file
plugins/ktcore/KTDocumentActions.php
... ... @@ -1242,25 +1242,6 @@ class KTDocumentCopyAction extends KTDocumentAction {
1242 1242  
1243 1243 $this->commitTransaction();
1244 1244  
1245   - // FIXME do we need to refactor all trigger usage into the util function?
1246   - $oKTTriggerRegistry = KTTriggerRegistry::getSingleton();
1247   - $aTriggers = $oKTTriggerRegistry->getTriggers('copyDocument', 'postValidate');
1248   - foreach ($aTriggers as $aTrigger) {
1249   - $sTrigger = $aTrigger[0];
1250   - $oTrigger = new $sTrigger;
1251   - $aInfo = array(
1252   - 'document' => $oNewDoc,
1253   - 'old_folder' => $this->oDocumentFolder,
1254   - 'new_folder' => $data['browse'],
1255   - );
1256   - $oTrigger->setInfo($aInfo);
1257   - $ret = $oTrigger->postValidate();
1258   - }
1259   -
1260   - //$aOptions = array('user' => $oUser);
1261   - //$oDocumentTransaction = & new DocumentTransaction($oNewDoc, 'Document copied from old version.', 'ktcore.transactions.create', $aOptions);
1262   - //$res = $oDocumentTransaction->create();
1263   -
1264 1245 $_SESSION['KTInfoMessage'][] = _kt('Document copied.');
1265 1246  
1266 1247 controllerRedirect('viewDocument', 'fDocumentId=' . $oNewDoc->getId());
... ...
plugins/ktcore/folder/Permissions.php
... ... @@ -132,7 +132,7 @@ class KTFolderPermissionsAction extends KTFolderAction {
132 132 // from a folder.
133 133 if ($oInherited->getId() !== $this->oFolder->getId()) {
134 134 $iInheritedFolderId = $oInherited->getId();
135   - $sInherited = join(' &raquo; ', $oInherited->getPathArray());
  135 + $sInherited = join(' > ', $oInherited->getPathArray());
136 136 }
137 137 // only allow inheritance if not inherited, -and- folders is editable
138 138 $bInheritable = $bEdit && ($oInherited->getId() !== $this->oFolder->getId());
... ...
plugins/ktstandard/SearchDashlet.php deleted
1   -<?php
2   -/**
3   - * $Id$
4   - *
5   - * The contents of this file are subject to the KnowledgeTree Public
6   - * License Version 1.1.2 ("License"); You may not use this file except in
7   - * compliance with the License. You may obtain a copy of the License at
8   - * http://www.knowledgetree.com/KPL
9   - *
10   - * Software distributed under the License is distributed on an "AS IS"
11   - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
12   - * See the License for the specific language governing rights and
13   - * limitations under the License.
14   - *
15   - * All copies of the Covered Code must include on each user interface screen:
16   - * (i) the "Powered by KnowledgeTree" logo and
17   - * (ii) the KnowledgeTree copyright notice
18   - * in the same form as they appear in the distribution. See the License for
19   - * requirements.
20   - *
21   - * The Original Code is: KnowledgeTree Open Source
22   - *
23   - * The Initial Developer of the Original Code is The Jam Warehouse Software
24   - * (Pty) Ltd, trading as KnowledgeTree.
25   - * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright
26   - * (C) 2007 The Jam Warehouse Software (Pty) Ltd;
27   - * All Rights Reserved.
28   - * Contributor( s): ______________________________________
29   - *
30   - */
31   -
32   -
33   -class SearchDashlet extends KTBaseDashlet {
34   - function SearchDashlet() {
35   - $this->sTitle = _kt('Search Dashlet');
36   - }
37   -
38   - function render() {
39   - $oTemplating =& KTTemplating::getSingleton();
40   - $oTemplate = $oTemplating->loadTemplate('ktstandard/searchdashlet/dashlet');
41   -
42   - $aSearches = KTSavedSearch::getSearches();
43   - // empty on error.
44   - if (PEAR::isError($aSearches)) {
45   - $aSearches = array();
46   - }
47   -
48   -
49   - $aTemplateData = array(
50   - 'savedsearches' => $aSearches,
51   - );
52   - return $oTemplate->render($aTemplateData);
53   - }
54   -}
55   -
56   -?>
57 0 \ No newline at end of file
plugins/ktstandard/SearchDashletPlugin.php deleted
1   -<?php
2   -/**
3   - * $Id$
4   - *
5   - * The contents of this file are subject to the KnowledgeTree Public
6   - * License Version 1.1.2 ("License"); You may not use this file except in
7   - * compliance with the License. You may obtain a copy of the License at
8   - * http://www.knowledgetree.com/KPL
9   - *
10   - * Software distributed under the License is distributed on an "AS IS"
11   - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
12   - * See the License for the specific language governing rights and
13   - * limitations under the License.
14   - *
15   - * All copies of the Covered Code must include on each user interface screen:
16   - * (i) the "Powered by KnowledgeTree" logo and
17   - * (ii) the KnowledgeTree copyright notice
18   - * in the same form as they appear in the distribution. See the License for
19   - * requirements.
20   - *
21   - * The Original Code is: KnowledgeTree Open Source
22   - *
23   - * The Initial Developer of the Original Code is The Jam Warehouse Software
24   - * (Pty) Ltd, trading as KnowledgeTree.
25   - * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright
26   - * (C) 2007 The Jam Warehouse Software (Pty) Ltd;
27   - * All Rights Reserved.
28   - * Contributor( s): ______________________________________
29   - *
30   - */
31   -
32   -require_once(KT_LIB_DIR . '/plugins/plugin.inc.php');
33   -require_once(KT_LIB_DIR . '/plugins/pluginregistry.inc.php');
34   -
35   -class SearchDashletPlugin extends KTPlugin {
36   - var $sNamespace = "ktstandard.searchdashlet.plugin";
37   - var $autoRegister = true;
38   -
39   - function SearchDashletPlugin($sFilename = null) {
40   - $res = parent::KTPlugin($sFilename);
41   - $this->sFriendlyName = _kt('Search Dashlet Plugin');
42   - return $res;
43   - }
44   -
45   - function setup() {
46   - $this->registerDashlet('SearchDashlet', 'ktstandard.searchdashlet.dashlet', 'SearchDashlet.php');
47   -
48   - require_once(KT_LIB_DIR . "/templating/templating.inc.php");
49   - $oTemplating =& KTTemplating::getSingleton();
50   - $oTemplating->addLocation('searchdashlet', '/plugins/searchdashlet/templates');
51   - }
52   -}
53   -
54   -$oPluginRegistry =& KTPluginRegistry::getSingleton();
55   -$oPluginRegistry->registerPlugin('SearchDashletPlugin', 'ktstandard.searchdashlet.plugin', __FILE__);
56   -?>
plugins/search2/Search2Portlet.php
... ... @@ -6,6 +6,7 @@ class Search2Portlet extends KTPortlet
6 6 function Search2Portlet()
7 7 {
8 8 parent::KTPortlet(_kt("Search"));
  9 + $this->bActive = true;
9 10 }
10 11  
11 12 function render()
... ...
plugins/tagcloud/TagCloudDashlet.php
... ... @@ -127,7 +127,6 @@ class TagCloudDashlet extends KTBaseDashlet {
127 127 }
128 128 list($where, $params, $joins) = KTSearchUtil::permissionToSQL($this->oUser, null);
129 129  
130   -
131 130 $sql = "
132 131 SELECT
133 132 TW.tag, count(*) as freq
... ... @@ -135,7 +134,6 @@ class TagCloudDashlet extends KTBaseDashlet {
135 134 document_tags DT INNER JOIN tag_words TW ON DT.tag_id=TW.id
136 135 WHERE DT.document_id in (SELECT D.id FROM documents D $joins WHERE $where) GROUP BY TW.tag";
137 136  
138   -
139 137 $tags = DBUtil::getResultArray(
140 138 array($sql,$params)
141 139  
... ...
plugins/tagcloud/TagCloudRedirectPage.php
... ... @@ -103,7 +103,8 @@ class TagCloudRedirectPage extends KTStandardDispatcher {
103 103  
104 104 $aOptions = $collection->getEnvironOptions(); // extract data from the environment
105 105  
106   - $aOptions['return_url'] = KTUtil::addQueryString('dashboard.php', false);
  106 + //$aOptions['return_url'] = KTUtil::addQueryString('dashboard.php', false);
  107 + $aOptions['return_url'] = KTUtil::addQueryString('TagCloudRedirection&tag='. $searchable_text, false );
107 108 $aOptions['empty_message'] = _kt('No documents or folders match this query.');
108 109 $aOptions['is_browse'] = true;
109 110  
... ...