Commit 8dc89ab8c7395e7275d52ea504779386f96ca35d
1 parent
cd0a813c
Merged in from DEV trunk...
KTS-2520 "Fatal Error when deleting a state in a workflow and selecting a replacement state." Fixed. Corrected cache clearing function call. Committed By: Kevin Fourie Reviewed By: Conrad Vermeulen WSA-55 "Allow users to be able to update the 'creator', 'created date', and other system fields via the KTAPI and web services" Updated. Committed By: Conrad Vermeulen Reviewed By: Kevin Fourie WSA-57 "Checkout functions should return document detail" Updated. WSA-56 "rename document_detail.updated fields to be document_detail.modified to be consistent with normal interface" Updated. Committed By: Conrad Vermeulen Reviewed By: Kevin Fourie WSA-58 "All functions working with documents should return document_detail structure. This allows for less chipy based communication" Fixed. WSA-57 "Checkout functions should return document detail" Fixed. WSA-58 covers this too. WSA-59 "Log incoming SOAP requests and outgoing responses based on the debug level" Fixed. WSA-55 "Allow users to be able to update the 'creator', 'created date', and other system fields via the KTAPI and web services" Updated. update_document_metadata allows for parameters to be passed. Committed By: Conrad Vermeulen Reviewed By: Kevin Fourie WSA-59 "Log incoming SOAP requests and outgoing responses based on the debug level" Deleted. Proxy not needed anymore. Committed By: Conrad Vermeulen Reviewed By: Kevin Fourie Reverted commit of "Forgot Password" functionality. It's still DEV. Committed By: Kevin Fourie Reviewed By: Jalaloedien Abrahams KTS-2683 "Bug with AnyMetadata search field as it does not pick up on metadata" Fixed. Committed By: Conrad Vermeulen Reviewed By: Kevin Fourie KTS-2647 "Folder utilisation dashlet should get the indexer location from the indexer and not from the config.ini" Fixed. Committed By: Conrad Vermeulen Reviewed By: Kevin Fourie KTS-2641 "indexing task should log start and stop as debug" Fixed. Committed By: Conrad Vermeulen Reviewed By: Kevin Fourie KTS-2639 "index optimisation task outputs name and indication when done" Fixed. Committed By: Conrad Vermeulen Reviewed By: Kevin Fourie KTS-2638 "index migration task should log start and stop as debug" Fixed. Committed By: Conrad Vermeulen Reviewed By: Kevin Fourie KTS-1112 "after auto log-out, re-login as different user gives old url" Fixed. Added a check to redirect to the dashboard if a different user logs back in after a logout or a timeout. Committed By: Jonathan Byrne Reviewed By: Jalaloedien Abrahams KTS-2672 "KTWebDAV move functions fail on litmus" Fixed. Corrected status messages. Adjusted rename to check for overwrite. KTS-2671 "KTWebDAV copy functions fail on litmus" Fixed. Corrected status messages. Added extra depth of '0'. Changed documentutil to accept a new document or folder name. Changed folderutil to allow a copy of only the folder, ignoring all subfolders and documents. BBS-1119 "Refactor move functions into ktapi" In progress. Cleaned up some functionality. Added in line documentation. BBS-1118 "Refactor copy functions into ktapi" In progress. Added in line documentation. KTS-2643 "basic tasks called by scheduler need to be in the source install" Updated. Committed By: Conrad Vermeulen Reviewed By: Megan Watson KTS-2687 "update the db install/upgrade scripts so that the php scripts that must be scheduled are referenced correctly" Updated. Committed By: Conrad Vermeulen Reviewed By: Megan Watson KTS-2690 "Strange character in search_ranking table. This may impact on ranking of search criteria." Updated. Committed By: Conrad Vermeulen Reviewed By: Megan Watson KTS-2688 "Index migration script should stop running when complete so script is not called unnecessarily" Updated. Committed By: Conrad Vermeulen Reviewed By: Megan Watson KTS-2575 "df.exe cannot be found by the Disk Usage dashlet" Fixed. Contributed By: Tahir Tahang Committed By: Conrad Vermeulen Reviewed By: Kevin Fourie KTS-1390 "A more precise error message needed when creating a duplicate of an already existing Permission" Fixed Added a more detailed error message system. Committed By: Jonathan Byrne Reviewed By: Kevin Fourie KTS-2697 "'between' operator is not working in the advanced search query builder" Fixed. Committed By: Conrad Vermeulen Reviewed By: Jalaloedien Abrahams KTS-2452 "Re-evaluate the placement, size and icon for the download icon" Fixed Changed download icon. Committed By: Jonathan Byrne Reviewed By: Kevin Fourie WSA-31 "copy_document seems to return an exception in c# even though it was successful." Fixed. Committed By: Conrad Vermeulen Reviewed By: Kevin Fourie KTS-1820 "Reachable folders being considered orphaned folders" Fixed. Added a check for folder details permission in addition to the check on read permission, in getBrowseableFolders(). Committed by: Megan Watson Reviewed by: Conrad Vermeulen KTS-2600 "Document Indexer Statistics Dashlet - improve text / US spelling / Capitalization / Link to Management Page" Updated. Dashlet text was improved.Also a image toggle has been added for the notes. Committed By:Yusuf Davids Reviewed By:Jalaloedien Abrahams KTS-2488 "Improve database incompatibility error message" Fixed. Error message changed. Committed By:Yusuf Davids Reviewed By:Jalaloedien Abrahams KTS-2488 "Improve database incompatibility error message" Fixed. Error message changed. Committed By:Yusuf Davids Reviewed By:Jalaloedien Abrahams KTS-2641 "indexing task should log start and stop as debug" Updated. Static function should not have $this Committed By: Conrad Vermeulen Reviewed By: Kevin Fourie WSA-63 "add add_document_with_metadata and checkin_document_with_metadata to webservice" Added. WSA-64 "Refactor the nunit tests a little" Updated. Committed By: Conrad Vermeulen Reviewed By: Kevin Fourie KTS-2705 "Comment length not being calculated properly in the Delete, Move, Archive, Check in, Check out comment fields." Fixed Both normal and utf-8 character sets lengths should be calculated correctly now. Committed By: Jonathan Byrne Reviewed By: Jalaloedien Abrahams KTS-2505 "Database configuration issues cause horrible knowledgetree failure" Fixed Added a check to stop any database calls in search if there is a database error. Committed By: Jonathan Byrne Reviewed By: Jalaloedien Abrahams KTS-2376 "When uploading .PNG image files these are incorrectly displayed as JPEG images" Fixed. Committed By: Conrad Vermeulen Reviewed By: Megan Watson WSA-65 "Remove php5 specific modifiers on functions so that web services works on both 3.4.x and 3.5.x" Updated. Committed By: Conrad Vermeulen Reviewed By: Martin Kirsten git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/STABLE/trunk@7698 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
51 changed files
with
2304 additions
and
1042 deletions
bin/scheduler.php
| @@ -88,20 +88,20 @@ function calculateRunTime($sFreq, $iTime) { | @@ -88,20 +88,20 @@ function calculateRunTime($sFreq, $iTime) { | ||
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | // Update the task information in the database | 90 | // Update the task information in the database |
| 91 | -function updateTask($sTable, $aFieldValues, $iId) { | ||
| 92 | - DBUtil::autoUpdate($sTable, $aFieldValues, $iId); | 91 | +function updateTask($aFieldValues, $iId) { |
| 92 | + DBUtil::autoUpdate('scheduler_tasks', $aFieldValues, $iId); | ||
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | // Get the list of tasks due to be run from the database | 95 | // Get the list of tasks due to be run from the database |
| 96 | -function getTaskList($sTable) { | 96 | +function getTaskList() { |
| 97 | $now = date('Y-m-d H:i:s'); //time(); | 97 | $now = date('Y-m-d H:i:s'); //time(); |
| 98 | - $query = "SELECT * FROM {$sTable} | ||
| 99 | - WHERE is_complete = 0 AND run_time < '{$now}'"; | 98 | + |
| 99 | + $query = "SELECT * FROM scheduler_tasks WHERE is_complete = 0 AND run_time < '{$now}'"; | ||
| 100 | 100 | ||
| 101 | $result = DBUtil::getResultArray($query); | 101 | $result = DBUtil::getResultArray($query); |
| 102 | 102 | ||
| 103 | if (PEAR::isError($result)){ | 103 | if (PEAR::isError($result)){ |
| 104 | - exit(); | 104 | + return false; |
| 105 | } | 105 | } |
| 106 | return $result; | 106 | return $result; |
| 107 | } | 107 | } |
| @@ -109,16 +109,22 @@ function getTaskList($sTable) { | @@ -109,16 +109,22 @@ function getTaskList($sTable) { | ||
| 109 | 109 | ||
| 110 | /* ** Scheduler script ** */ | 110 | /* ** Scheduler script ** */ |
| 111 | 111 | ||
| 112 | -$sTable = 'scheduler_tasks'; | 112 | +global $default; |
| 113 | 113 | ||
| 114 | -// Get task list | ||
| 115 | -$aList = getTaskList($sTable); | 114 | +$default->log->debug('Scheduler: starting'); |
| 116 | 115 | ||
| 117 | -global $default; | 116 | +// Get task list |
| 117 | +$aList = getTaskList(); | ||
| 118 | +if (empty($aList)) | ||
| 119 | +{ | ||
| 120 | + $default->log->debug('Scheduler: stopping - nothing to do'); | ||
| 121 | + return; | ||
| 122 | +} | ||
| 118 | 123 | ||
| 119 | // Loop through tasks and run | 124 | // Loop through tasks and run |
| 120 | -if(!empty($aList)){ | ||
| 121 | - foreach($aList as $item){ | 125 | + |
| 126 | + foreach($aList as $item) | ||
| 127 | + { | ||
| 122 | $aUpdate = array(); | 128 | $aUpdate = array(); |
| 123 | $iEnd = 0; $iStart = 0; $iDuration = 0; | 129 | $iEnd = 0; $iStart = 0; $iDuration = 0; |
| 124 | $sFreq = ''; $sParameters = ''; | 130 | $sFreq = ''; $sParameters = ''; |
| @@ -132,64 +138,84 @@ if(!empty($aList)){ | @@ -132,64 +138,84 @@ if(!empty($aList)){ | ||
| 132 | $sParameters = $item['script_params']; | 138 | $sParameters = $item['script_params']; |
| 133 | 139 | ||
| 134 | // Check if script is windows or *nix compatible | 140 | // Check if script is windows or *nix compatible |
| 135 | - $extArr = explode('.', $sTaskUrl); | ||
| 136 | - $ext = array_pop($extArr); | ||
| 137 | - $script = implode('.', $extArr); | ||
| 138 | - if(OS_WINDOWS){ | ||
| 139 | - switch($ext){ | ||
| 140 | - case 'sh': | ||
| 141 | - $sTaskUrl = $script.'.bat'; | ||
| 142 | - break; | ||
| 143 | - case 'bin': | ||
| 144 | - $sTaskUrl = $script.'.exe'; | ||
| 145 | - break; | ||
| 146 | - } | ||
| 147 | - }else{ | ||
| 148 | - switch($ext){ | ||
| 149 | - case 'bat': | ||
| 150 | - if(file_exists(KT_DIR . $script.'.sh')){ | ||
| 151 | - $sTaskUrl = $script.'.sh'; | ||
| 152 | - break; | ||
| 153 | - } | ||
| 154 | - // File doesn't exist - log error | ||
| 155 | - $default->log->error("Scheduler: Task script can't be found at ".KT_DIR."{$script}.sh"); | ||
| 156 | - continue; | ||
| 157 | - break; | ||
| 158 | - case 'exe': | ||
| 159 | - if(file_exists(KT_DIR . $script)){ | ||
| 160 | - $sTaskUrl = $script; | ||
| 161 | - break; | ||
| 162 | - } | ||
| 163 | - if(file_exists(KT_DIR . $script.'.bin')){ | ||
| 164 | - $sTaskUrl = $script.'.bin'; | ||
| 165 | - break; | ||
| 166 | - } | ||
| 167 | - // File doesn't exist - log error | ||
| 168 | - $default->log->error("Scheduler: Task script can't be found at ".KT_DIR."{$script} or ".KT_DIR."{$script}.bin"); | ||
| 169 | - continue; | ||
| 170 | - break; | ||
| 171 | - } | 141 | + $ext = pathinfo($sTaskUrl, PATHINFO_EXTENSION); |
| 142 | + $script = substr($sTaskUrl,0,-strlen($ext)-1); | ||
| 143 | + | ||
| 144 | + if(OS_WINDOWS) | ||
| 145 | + { | ||
| 146 | + $mapping = array('sh'=>'bin','bat'=>'exe'); | ||
| 147 | + if (array_key_exists($ext, $mapping)) | ||
| 148 | + { | ||
| 149 | + $sTaskUrl = $script . '.' . $mapping[$ext]; | ||
| 150 | + } | ||
| 151 | + } | ||
| 152 | + else | ||
| 153 | + { | ||
| 154 | + $mapping = array('bat'=>'sh', 'exe'=>'bin'); | ||
| 155 | + | ||
| 156 | + if (array_key_exists($ext, $mapping)) | ||
| 157 | + { | ||
| 158 | + switch ($ext) | ||
| 159 | + { | ||
| 160 | + case 'exe': | ||
| 161 | + if (is_executable(KT_DIR . '/' . $script)) | ||
| 162 | + { | ||
| 163 | + $sTaskUrl = $script; | ||
| 164 | + break; | ||
| 165 | + } | ||
| 166 | + default: | ||
| 167 | + $sTaskUrl = $script . '.' . $mapping[$ext]; | ||
| 168 | + } | ||
| 169 | + } | ||
| 170 | + | ||
| 171 | + if (!is_executable(KT_DIR . '/' . $script) && $ext != 'php') | ||
| 172 | + { | ||
| 173 | + $default->log->error("Scheduler: The script '{$sTaskUrl}' is not executable."); | ||
| 174 | + continue; | ||
| 175 | + } | ||
| 176 | + } | ||
| 177 | + | ||
| 178 | + $file = realpath(KT_DIR . '/' . $sTaskUrl); | ||
| 179 | + | ||
| 180 | + if ($file === false) | ||
| 181 | + { | ||
| 182 | + $default->log->error("Scheduler: The script '{$sTaskUrl}' cannot be resolved."); | ||
| 183 | + continue; | ||
| 172 | } | 184 | } |
| 173 | 185 | ||
| 174 | $iTime = time(); | 186 | $iTime = time(); |
| 175 | - $iStart = explode(' ', microtime()); | 187 | + $iStart = KTUtil::getBenchmarkTime(); |
| 176 | 188 | ||
| 177 | // Run the script | 189 | // Run the script |
| 178 | - $file = realpath(KT_DIR . '/' . $sTaskUrl); | ||
| 179 | 190 | ||
| 180 | $cmd = "\"$file\" {$sParameters}"; | 191 | $cmd = "\"$file\" {$sParameters}"; |
| 181 | 192 | ||
| 182 | - $start = KTUtil::getBenchmarkTime(); | 193 | + if ($ext == 'php') |
| 194 | + { | ||
| 195 | + $config = KTConfig::getSingleton(); | ||
| 196 | + $phpPath = $config->get('externalBinary/php'); | ||
| 197 | + | ||
| 198 | + // being protective as some scripts work on relative paths | ||
| 199 | + $dirname = dirname($file); | ||
| 200 | + chdir($dirname); | ||
| 201 | + | ||
| 202 | + $cmd = "$phpPath $cmd"; | ||
| 203 | + } | ||
| 204 | + | ||
| 183 | if (OS_WINDOWS) | 205 | if (OS_WINDOWS) |
| 184 | { | 206 | { |
| 185 | $cmd = str_replace( '/','\\',$cmd); | 207 | $cmd = str_replace( '/','\\',$cmd); |
| 186 | - $res = `"$cmd" 2>&1`; | 208 | + $res = `$cmd`; |
| 187 | } | 209 | } |
| 188 | else | 210 | else |
| 189 | { | 211 | { |
| 190 | $res = shell_exec($cmd." 2>&1"); | 212 | $res = shell_exec($cmd." 2>&1"); |
| 191 | } | 213 | } |
| 192 | 214 | ||
| 215 | + // On completion - reset run time | ||
| 216 | + $iEnd = KTUtil::getBenchmarkTime(); | ||
| 217 | + $iDuration = number_format($iEnd - $iStart,2); | ||
| 218 | + | ||
| 193 | if (!empty($res)) | 219 | if (!empty($res)) |
| 194 | { | 220 | { |
| 195 | $default->log->info("Scheduler - Task: $sTask"); | 221 | $default->log->info("Scheduler - Task: $sTask"); |
| @@ -199,37 +225,26 @@ if(!empty($aList)){ | @@ -199,37 +225,26 @@ if(!empty($aList)){ | ||
| 199 | } | 225 | } |
| 200 | else | 226 | else |
| 201 | { | 227 | { |
| 202 | - $time = number_format(KTUtil::getBenchmarkTime() - $start,2,'.',','); | ||
| 203 | - $default->log->debug("Scheduler - Task: {$sTask} completed in {$diff}s."); | 228 | + $default->log->debug("Scheduler - Task: {$sTask} completed in {$iDuration}s."); |
| 204 | } | 229 | } |
| 205 | 230 | ||
| 206 | - | ||
| 207 | - // On completion - reset run time | ||
| 208 | - $iEnd = explode(' ', microtime()); | ||
| 209 | - $iDuration = ($iEnd[1] + $iEnd[0]) - ($iStart[1] + $iStart[0]); | ||
| 210 | - $iDuration = round($iDuration, 3); | ||
| 211 | - | ||
| 212 | - if(($sFreq == 'once' || empty($sFreq)) && $retval !== FALSE){ | 231 | + if(($sFreq == 'once' || empty($sFreq)) && $retval !== FALSE) |
| 232 | + { | ||
| 213 | // Set is_complete to true | 233 | // Set is_complete to true |
| 214 | $aUpdate['is_complete'] = '1'; | 234 | $aUpdate['is_complete'] = '1'; |
| 215 | - }else{ | 235 | + } |
| 236 | + else | ||
| 237 | + { | ||
| 216 | $iNextTime = calculateRunTime($sFreq, $iTime); | 238 | $iNextTime = calculateRunTime($sFreq, $iTime); |
| 217 | $aUpdate['run_time'] = date('Y-m-d H:i:s', $iNextTime); | 239 | $aUpdate['run_time'] = date('Y-m-d H:i:s', $iNextTime); |
| 218 | } | 240 | } |
| 241 | + | ||
| 219 | $aUpdate['previous_run_time'] = date('Y-m-d H:i:s', $iTime); | 242 | $aUpdate['previous_run_time'] = date('Y-m-d H:i:s', $iTime); |
| 220 | $aUpdate['run_duration'] = $iDuration; | 243 | $aUpdate['run_duration'] = $iDuration; |
| 221 | 244 | ||
| 222 | - updateTask($sTable, $aUpdate, $item['id']); | ||
| 223 | - | ||
| 224 | - // clear parameters | ||
| 225 | - if(!empty($aParams)){ | ||
| 226 | - foreach($aParams as $param){ | ||
| 227 | - $aParam = explode('=', $param); | ||
| 228 | - $$aParam[0] = ''; | ||
| 229 | - } | ||
| 230 | - $aParam = array(); | ||
| 231 | - $aParams = array(); | ||
| 232 | - } | 245 | + updateTask($aUpdate, $item['id']); |
| 233 | } | 246 | } |
| 234 | -} | 247 | + |
| 248 | +$default->log->debug('Scheduler: stopping'); | ||
| 249 | + | ||
| 235 | ?> | 250 | ?> |
| 236 | \ No newline at end of file | 251 | \ No newline at end of file |
control.php
| 1 | <?php | 1 | <?php |
| 2 | /* | 2 | /* |
| 3 | - * $Id:$ | 3 | + * $Id$ |
| 4 | * | 4 | * |
| 5 | * KnowledgeTree Open Source Edition | 5 | * KnowledgeTree Open Source Edition |
| 6 | * Document Management Made Simple | 6 | * Document Management Made Simple |
| @@ -81,6 +81,8 @@ if ($action != 'login') { | @@ -81,6 +81,8 @@ if ($action != 'login') { | ||
| 81 | } | 81 | } |
| 82 | if (PEAR::isError($ret)) { | 82 | if (PEAR::isError($ret)) { |
| 83 | $url = $url . '&errorMessage=' . urlencode($ret->getMessage()); | 83 | $url = $url . '&errorMessage=' . urlencode($ret->getMessage()); |
| 84 | + session_start(); | ||
| 85 | + $_SESSION['errormessage']['login'] = $ret->getMessage(); | ||
| 84 | } | 86 | } |
| 85 | redirect($url); | 87 | redirect($url); |
| 86 | exit(0); | 88 | exit(0); |
i18n/knowledgeTree.pot
| @@ -4062,8 +4062,32 @@ msgstr "" | @@ -4062,8 +4062,32 @@ msgstr "" | ||
| 4062 | msgid "Error creating allocation" | 4062 | msgid "Error creating allocation" |
| 4063 | msgstr "" | 4063 | msgstr "" |
| 4064 | 4064 | ||
| 4065 | -#: plugins/ktcore/admin/managePermissions.php:76 | ||
| 4066 | -msgid "Error creating permission" | 4065 | +#: plugins/ktcore/admin/managePermissions.php:81 |
| 4066 | +msgid "An error occured while creating your permission" | ||
| 4067 | +msgstr "" | ||
| 4068 | + | ||
| 4069 | +#: plugins/ktcore/admin/managePermissions.php:86 | ||
| 4070 | +msgid "An error occured while creating your permission: The System Name was not provided." | ||
| 4071 | +msgstr "" | ||
| 4072 | + | ||
| 4073 | +#: plugins/ktcore/admin/managePermissions.php:92 | ||
| 4074 | +msgid "An error occured while creating your permission: The Display Name was not provided." | ||
| 4075 | +msgstr "" | ||
| 4076 | + | ||
| 4077 | +#: plugins/ktcore/admin/managePermissions.php:98 | ||
| 4078 | +msgid "An error occured while creating your permission: The Display Name and System Name weren't provided." | ||
| 4079 | +msgstr "" | ||
| 4080 | + | ||
| 4081 | +#: plugins/ktcore/admin/managePermissions.php:120 | ||
| 4082 | +msgid "An error occured while creating your permission: The Display Name and System Name you have provided both already exist." | ||
| 4083 | +msgstr "" | ||
| 4084 | + | ||
| 4085 | +#: plugins/ktcore/admin/managePermissions.php:129 | ||
| 4086 | +msgid "An error occured while creating your permission: A permission with the same System Name already exists." | ||
| 4087 | +msgstr "" | ||
| 4088 | + | ||
| 4089 | +#: plugins/ktcore/admin/managePermissions.php:138 | ||
| 4090 | +msgid "An error occured while creating your permission: A permission with the same Display Name already exists." | ||
| 4067 | msgstr "" | 4091 | msgstr "" |
| 4068 | 4092 | ||
| 4069 | #: plugins/ktcore/admin/managePermissions.php:95 | 4093 | #: plugins/ktcore/admin/managePermissions.php:95 |
ktapi/KTAPIDocument.inc.php
| @@ -5,32 +5,32 @@ | @@ -5,32 +5,32 @@ | ||
| 5 | * KnowledgeTree Open Source Edition | 5 | * KnowledgeTree Open Source Edition |
| 6 | * Document Management Made Simple | 6 | * Document Management Made Simple |
| 7 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited | 7 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited |
| 8 | - * | 8 | + * |
| 9 | * This program is free software; you can redistribute it and/or modify it under | 9 | * This program is free software; you can redistribute it and/or modify it under |
| 10 | * the terms of the GNU General Public License version 3 as published by the | 10 | * the terms of the GNU General Public License version 3 as published by the |
| 11 | * Free Software Foundation. | 11 | * Free Software Foundation. |
| 12 | - * | 12 | + * |
| 13 | * This program is distributed in the hope that it will be useful, but WITHOUT | 13 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | 15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 16 | * details. | 16 | * details. |
| 17 | - * | 17 | + * |
| 18 | * You should have received a copy of the GNU General Public License | 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | - * | 20 | + * |
| 21 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, | 21 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, |
| 22 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. | 22 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. |
| 23 | - * | 23 | + * |
| 24 | * The interactive user interfaces in modified source and object code versions | 24 | * The interactive user interfaces in modified source and object code versions |
| 25 | * of this program must display Appropriate Legal Notices, as required under | 25 | * of this program must display Appropriate Legal Notices, as required under |
| 26 | * Section 5 of the GNU General Public License version 3. | 26 | * Section 5 of the GNU General Public License version 3. |
| 27 | - * | 27 | + * |
| 28 | * In accordance with Section 7(b) of the GNU General Public License version 3, | 28 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 29 | * these Appropriate Legal Notices must retain the display of the "Powered by | 29 | * these Appropriate Legal Notices must retain the display of the "Powered by |
| 30 | - * KnowledgeTree" logo and retain the original copyright notice. If the display of the | 30 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the |
| 31 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | 31 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices |
| 32 | - * must display the words "Powered by KnowledgeTree" and retain the original | ||
| 33 | - * copyright notice. | 32 | + * must display the words "Powered by KnowledgeTree" and retain the original |
| 33 | + * copyright notice. | ||
| 34 | * Contributor( s): ______________________________________ | 34 | * Contributor( s): ______________________________________ |
| 35 | * | 35 | * |
| 36 | */ | 36 | */ |
| @@ -314,13 +314,16 @@ class KTAPI_Document extends KTAPI_FolderItem | @@ -314,13 +314,16 @@ class KTAPI_Document extends KTAPI_FolderItem | ||
| 314 | { | 314 | { |
| 315 | continue; | 315 | continue; |
| 316 | } | 316 | } |
| 317 | + | ||
| 318 | + | ||
| 319 | + | ||
| 317 | $result[] = array( | 320 | $result[] = array( |
| 318 | 'document_id'=>(int)$row['document_id'], | 321 | 'document_id'=>(int)$row['document_id'], |
| 319 | 'title'=> $row['title'], | 322 | 'title'=> $row['title'], |
| 320 | 'size'=>(int)$row['size'], | 323 | 'size'=>(int)$row['size'], |
| 321 | - 'workflow'=>$row['workflow'], | ||
| 322 | - 'workflow_state'=>$row['workflow_state'], | ||
| 323 | - 'link_type'=>$row['link_type'], | 324 | + 'workflow'=>empty($row['workflow'])?'n/a':$row['workflow'], |
| 325 | + 'workflow_state'=>empty($row['workflow_state'])?'n/a':$row['workflow_state'], | ||
| 326 | + 'link_type'=>empty($row['link_type'])?'unknown':$row['link_type'], | ||
| 324 | ); | 327 | ); |
| 325 | } | 328 | } |
| 326 | 329 | ||
| @@ -447,6 +450,7 @@ class KTAPI_Document extends KTAPI_FolderItem | @@ -447,6 +450,7 @@ class KTAPI_Document extends KTAPI_FolderItem | ||
| 447 | * @param string $reason | 450 | * @param string $reason |
| 448 | * @param string $newname | 451 | * @param string $newname |
| 449 | * @param string $newfilename | 452 | * @param string $newfilename |
| 453 | + * @return KTAPI_Document | ||
| 450 | */ | 454 | */ |
| 451 | function copy(&$ktapi_target_folder, $reason, $newname=null, $newfilename=null) | 455 | function copy(&$ktapi_target_folder, $reason, $newname=null, $newfilename=null) |
| 452 | { | 456 | { |
| @@ -533,12 +537,14 @@ class KTAPI_Document extends KTAPI_FolderItem | @@ -533,12 +537,14 @@ class KTAPI_Document extends KTAPI_FolderItem | ||
| 533 | $oTrigger = new $sTrigger; | 537 | $oTrigger = new $sTrigger; |
| 534 | $aInfo = array( | 538 | $aInfo = array( |
| 535 | 'document' => $new_document, | 539 | 'document' => $new_document, |
| 536 | - 'old_folder' => $this->folder->get_folder(), | 540 | + 'old_folder' => $this->ktapi_folder->get_folder(), |
| 537 | 'new_folder' => $target_folder, | 541 | 'new_folder' => $target_folder, |
| 538 | ); | 542 | ); |
| 539 | $oTrigger->setInfo($aInfo); | 543 | $oTrigger->setInfo($aInfo); |
| 540 | $ret = $oTrigger->postValidate(); | 544 | $ret = $oTrigger->postValidate(); |
| 541 | } | 545 | } |
| 546 | + | ||
| 547 | + return KTAPI_Document::get($this->ktapi, $new_document->getId()); | ||
| 542 | } | 548 | } |
| 543 | 549 | ||
| 544 | /** | 550 | /** |
| @@ -676,6 +682,10 @@ class KTAPI_Document extends KTAPI_FolderItem | @@ -676,6 +682,10 @@ class KTAPI_Document extends KTAPI_FolderItem | ||
| 676 | } | 682 | } |
| 677 | 683 | ||
| 678 | $doctypeid = KTAPI::get_documenttypeid($documenttype); | 684 | $doctypeid = KTAPI::get_documenttypeid($documenttype); |
| 685 | + if (PEAR::isError($doctypeid)) | ||
| 686 | + { | ||
| 687 | + return $doctypeid; | ||
| 688 | + } | ||
| 679 | 689 | ||
| 680 | if ($this->document->getDocumentTypeId() != $doctypeid) | 690 | if ($this->document->getDocumentTypeId() != $doctypeid) |
| 681 | { | 691 | { |
| @@ -836,7 +846,7 @@ class KTAPI_Document extends KTAPI_FolderItem | @@ -836,7 +846,7 @@ class KTAPI_Document extends KTAPI_FolderItem | ||
| 836 | } | 846 | } |
| 837 | 847 | ||
| 838 | $workflowid=$this->document->getWorkflowId(); | 848 | $workflowid=$this->document->getWorkflowId(); |
| 839 | - if (!empty($workflowid)) | 849 | + if (empty($workflowid)) |
| 840 | { | 850 | { |
| 841 | return new PEAR_Error(KTAPI_ERROR_WORKFLOW_NOT_IN_PROGRESS); | 851 | return new PEAR_Error(KTAPI_ERROR_WORKFLOW_NOT_IN_PROGRESS); |
| 842 | } | 852 | } |
| @@ -1045,6 +1055,11 @@ class KTAPI_Document extends KTAPI_FolderItem | @@ -1045,6 +1055,11 @@ class KTAPI_Document extends KTAPI_FolderItem | ||
| 1045 | function update_metadata($metadata) | 1055 | function update_metadata($metadata) |
| 1046 | { | 1056 | { |
| 1047 | global $default; | 1057 | global $default; |
| 1058 | + if (empty($metadata)) | ||
| 1059 | + { | ||
| 1060 | + return; | ||
| 1061 | + } | ||
| 1062 | + | ||
| 1048 | $packed = $this->get_packed_metadata($metadata); | 1063 | $packed = $this->get_packed_metadata($metadata); |
| 1049 | 1064 | ||
| 1050 | DBUtil::startTransaction(); | 1065 | DBUtil::startTransaction(); |
| @@ -1079,6 +1094,233 @@ class KTAPI_Document extends KTAPI_FolderItem | @@ -1079,6 +1094,233 @@ class KTAPI_Document extends KTAPI_FolderItem | ||
| 1079 | 1094 | ||
| 1080 | } | 1095 | } |
| 1081 | 1096 | ||
| 1097 | + /** | ||
| 1098 | + * This updates the system metadata on the document. | ||
| 1099 | + * | ||
| 1100 | + * @param array $sysdata | ||
| 1101 | + */ | ||
| 1102 | + function update_sysdata($sysdata) | ||
| 1103 | + { | ||
| 1104 | + if (empty($sysdata)) | ||
| 1105 | + { | ||
| 1106 | + return; | ||
| 1107 | + } | ||
| 1108 | + $owner_mapping = array( | ||
| 1109 | + 'created_by'=>'creator_id', | ||
| 1110 | + 'modified_by'=>'modified_user_id', | ||
| 1111 | + 'owner'=>'owner_id' | ||
| 1112 | + ); | ||
| 1113 | + | ||
| 1114 | + $documents = array(); | ||
| 1115 | + $document_content = array(); | ||
| 1116 | + | ||
| 1117 | + foreach($sysdata as $rec) | ||
| 1118 | + { | ||
| 1119 | + if (is_object($rec)) | ||
| 1120 | + { | ||
| 1121 | + $name = $rec->name; | ||
| 1122 | + $value = sanitizeForSQL($rec->value); | ||
| 1123 | + } | ||
| 1124 | + elseif(is_array($rec)) | ||
| 1125 | + { | ||
| 1126 | + $name = $rec['name']; | ||
| 1127 | + $value = sanitizeForSQL($rec['value']); | ||
| 1128 | + } | ||
| 1129 | + else | ||
| 1130 | + { | ||
| 1131 | + // just ignore | ||
| 1132 | + continue; | ||
| 1133 | + } | ||
| 1134 | + switch($name) | ||
| 1135 | + { | ||
| 1136 | + case 'created_date': | ||
| 1137 | + $documents['created'] = $value; | ||
| 1138 | + break; | ||
| 1139 | + case 'modified_date': | ||
| 1140 | + $documents['modified'] = $value; | ||
| 1141 | + break; | ||
| 1142 | + case 'is_immutable': | ||
| 1143 | + $documents['immutable'] = in_array(strtolower($value), array('1','true','on','yes'))?'1':'0'; | ||
| 1144 | + break; | ||
| 1145 | + case 'filename': | ||
| 1146 | + $document_content['filename'] = $value; | ||
| 1147 | + break; | ||
| 1148 | + case 'major_version': | ||
| 1149 | + $document_content['major_version'] = $value; | ||
| 1150 | + break; | ||
| 1151 | + case 'minor_version': | ||
| 1152 | + $document_content['minor_version'] = $value; | ||
| 1153 | + break; | ||
| 1154 | + case 'version': | ||
| 1155 | + $version = number_format($value + 0,5); | ||
| 1156 | + list($major_version, $minor_version) = explode('.', $version); | ||
| 1157 | + $document_content['major_version'] = $major_version; | ||
| 1158 | + $document_content['minor_version'] = $minor_version; | ||
| 1159 | + break; | ||
| 1160 | + case 'mime_type': | ||
| 1161 | + $sql = "select id from mime_types where mimetypes='$value'"; | ||
| 1162 | + $value = DBUtil::getResultArray($sql); | ||
| 1163 | + if (PEAR::isError($value)) | ||
| 1164 | + { | ||
| 1165 | + return $value; | ||
| 1166 | + } | ||
| 1167 | + if (count($value) == 0) | ||
| 1168 | + { | ||
| 1169 | + break; | ||
| 1170 | + } | ||
| 1171 | + $value = $value[0]['id']; | ||
| 1172 | + $document_content['mime_id'] = $value; | ||
| 1173 | + break; | ||
| 1174 | + case 'owner': | ||
| 1175 | + case 'created_by': | ||
| 1176 | + case 'modified_by': | ||
| 1177 | + $sql = "select id from users where name='$value'"; | ||
| 1178 | + $userId = DBUtil::getResultArray($sql); | ||
| 1179 | + if (PEAR::isError($userId)) | ||
| 1180 | + { | ||
| 1181 | + return $userId; | ||
| 1182 | + } | ||
| 1183 | + if (empty($userId)) | ||
| 1184 | + { | ||
| 1185 | + $sql = "select id from users where username='$value'"; | ||
| 1186 | + $userId = DBUtil::getResultArray($sql); | ||
| 1187 | + if (PEAR::isError($userId)) | ||
| 1188 | + { | ||
| 1189 | + return $userId; | ||
| 1190 | + } | ||
| 1191 | + } | ||
| 1192 | + if (empty($userId)) | ||
| 1193 | + { | ||
| 1194 | + // if not found, not much we can do | ||
| 1195 | + break; | ||
| 1196 | + } | ||
| 1197 | + $userId=$userId[0]; | ||
| 1198 | + $userId=$userId['id']; | ||
| 1199 | + | ||
| 1200 | + $name = $owner_mapping[$name]; | ||
| 1201 | + $documents[$name] = $userId; | ||
| 1202 | + break; | ||
| 1203 | + default: | ||
| 1204 | + // TODO: we should do some logging | ||
| 1205 | + //return new PEAR_Error('Unexpected field: ' . $name); | ||
| 1206 | + } | ||
| 1207 | + } | ||
| 1208 | + | ||
| 1209 | + if (count($documents) > 0) | ||
| 1210 | + { | ||
| 1211 | + $sql = "UPDATE documents SET "; | ||
| 1212 | + $i=0; | ||
| 1213 | + foreach($documents as $name=>$value) | ||
| 1214 | + { | ||
| 1215 | + if ($i++ > 0) $sql .= ","; | ||
| 1216 | + if (is_numeric($value)) | ||
| 1217 | + $sql .= "$name=$value"; | ||
| 1218 | + else | ||
| 1219 | + $sql .= "$name='$value'"; | ||
| 1220 | + } | ||
| 1221 | + $sql .= " WHERE id=$this->documentid"; | ||
| 1222 | + $result = DBUtil::runQuery($sql); | ||
| 1223 | + if (PEAR::isError($result)) | ||
| 1224 | + { | ||
| 1225 | + return $result; | ||
| 1226 | + } | ||
| 1227 | + } | ||
| 1228 | + if (count($document_content) > 0) | ||
| 1229 | + { | ||
| 1230 | + $content_id = $this->document->getContentVersionId(); | ||
| 1231 | + $sql = "UPDATE document_content_version SET "; | ||
| 1232 | + $i=0; | ||
| 1233 | + foreach($document_content as $name=>$value) | ||
| 1234 | + { | ||
| 1235 | + if ($i++ > 0) $sql .= ","; | ||
| 1236 | + $sql .= "$name='$value'"; | ||
| 1237 | + } | ||
| 1238 | + $sql .= " WHERE id=$content_id"; | ||
| 1239 | + $result = DBUtil::runQuery($sql); | ||
| 1240 | + if (PEAR::isError($result)) | ||
| 1241 | + { | ||
| 1242 | + return $result; | ||
| 1243 | + } | ||
| 1244 | + } | ||
| 1245 | + } | ||
| 1246 | + | ||
| 1247 | + function clearCache() | ||
| 1248 | + { | ||
| 1249 | + // TODO: we should only clear the cache for the document we are working on | ||
| 1250 | + // this is a quick fix but not optimal!! | ||
| 1251 | + | ||
| 1252 | + | ||
| 1253 | + $metadataid = $this->document->getMetadataVersionId(); | ||
| 1254 | + $contentid = $this->document->getContentVersionId(); | ||
| 1255 | + | ||
| 1256 | + $cache = KTCache::getSingleton(); | ||
| 1257 | + | ||
| 1258 | + $cache->remove('KTDocumentMetadataVersion/id', $metadataid); | ||
| 1259 | + $cache->remove('KTDocumentContentVersion/id', $contentid); | ||
| 1260 | + $cache->remove('KTDocumentCore/id', $this->documentid); | ||
| 1261 | + $cache->remove('Document/id', $this->documentid); | ||
| 1262 | + unset($GLOBALS['_OBJECTCACHE']['KTDocumentMetadataVersion'][$metadataid]); | ||
| 1263 | + unset($GLOBALS['_OBJECTCACHE']['KTDocumentContentVersion'][$contentid]); | ||
| 1264 | + unset($GLOBALS['_OBJECTCACHE']['KTDocumentCore'][$this->documentid]); | ||
| 1265 | + | ||
| 1266 | + $this->document = &Document::get($this->documentid); | ||
| 1267 | + } | ||
| 1268 | + | ||
| 1269 | + function mergeWithLastMetadataVersion() | ||
| 1270 | + { | ||
| 1271 | + // keep latest metadata version | ||
| 1272 | + $metadata_version = $this->document->getMetadataVersion(); | ||
| 1273 | + if ($metadata_version == 0) | ||
| 1274 | + { | ||
| 1275 | + // this could theoretically happen in the case we are updating metadata and sysdata, but no metadata fields are specified. | ||
| 1276 | + return; | ||
| 1277 | + } | ||
| 1278 | + | ||
| 1279 | + $metadata_id = $this->document->getMetadataVersionId(); | ||
| 1280 | + | ||
| 1281 | + // get previous version | ||
| 1282 | + $sql = "SELECT id, metadata_version FROM document_metadata_version WHERE id<$metadata_id AND document_id=$this->documentid order by id desc"; | ||
| 1283 | + $old = DBUtil::getResultArray($sql); | ||
| 1284 | + if (is_null($old) || PEAR::isError($old)) | ||
| 1285 | + { | ||
| 1286 | + return new PEAR_Error('Previous version could not be resolved'); | ||
| 1287 | + } | ||
| 1288 | + // only interested in the first one | ||
| 1289 | + $old=$old[0]; | ||
| 1290 | + $old_metadata_id = $old['id']; | ||
| 1291 | + $old_metadata_version = $old['metadata_version']; | ||
| 1292 | + | ||
| 1293 | + DBUtil::startTransaction(); | ||
| 1294 | + | ||
| 1295 | + // delete previous metadata version | ||
| 1296 | + | ||
| 1297 | + $sql = "DELETE FROM document_metadata_version WHERE id=$old_metadata_id"; | ||
| 1298 | + $rs = DBUtil::runQuery($sql); | ||
| 1299 | + if (PEAR::isError($rs)) | ||
| 1300 | + { | ||
| 1301 | + DBUtil::rollback(); | ||
| 1302 | + return $rs; | ||
| 1303 | + } | ||
| 1304 | + | ||
| 1305 | + // make latest equal to previous | ||
| 1306 | + $sql = "UPDATE document_metadata_version SET metadata_version=$old_metadata_version WHERE id=$metadata_id"; | ||
| 1307 | + $rs = DBUtil::runQuery($sql); | ||
| 1308 | + if (PEAR::isError($rs)) | ||
| 1309 | + { | ||
| 1310 | + DBUtil::rollback(); | ||
| 1311 | + return $rs; | ||
| 1312 | + } | ||
| 1313 | + $sql = "UPDATE documents SET metadata_version=$old_metadata_version WHERE id=$this->documentid"; | ||
| 1314 | + $rs = DBUtil::runQuery($sql); | ||
| 1315 | + if (PEAR::isError($rs)) | ||
| 1316 | + { | ||
| 1317 | + DBUtil::rollback(); | ||
| 1318 | + return $rs; | ||
| 1319 | + } | ||
| 1320 | + DBUtil::commit(); | ||
| 1321 | + | ||
| 1322 | + $this->clearCache(); | ||
| 1323 | + } | ||
| 1082 | 1324 | ||
| 1083 | /** | 1325 | /** |
| 1084 | * This returns a workflow transition | 1326 | * This returns a workflow transition |
| @@ -1156,6 +1398,10 @@ class KTAPI_Document extends KTAPI_FolderItem | @@ -1156,6 +1398,10 @@ class KTAPI_Document extends KTAPI_FolderItem | ||
| 1156 | */ | 1398 | */ |
| 1157 | function get_detail() | 1399 | function get_detail() |
| 1158 | { | 1400 | { |
| 1401 | + global $default; | ||
| 1402 | + // make sure we ge tthe latest | ||
| 1403 | + $this->clearCache(); | ||
| 1404 | + | ||
| 1159 | $detail = array(); | 1405 | $detail = array(); |
| 1160 | $document = $this->document; | 1406 | $document = $this->document; |
| 1161 | 1407 | ||
| @@ -1191,6 +1437,7 @@ class KTAPI_Document extends KTAPI_FolderItem | @@ -1191,6 +1437,7 @@ class KTAPI_Document extends KTAPI_FolderItem | ||
| 1191 | } | 1437 | } |
| 1192 | $detail['created_by'] = $username; | 1438 | $detail['created_by'] = $username; |
| 1193 | $detail['updated_date'] = $document->getLastModifiedDate(); | 1439 | $detail['updated_date'] = $document->getLastModifiedDate(); |
| 1440 | + $detail['modified_date'] = $document->getLastModifiedDate(); | ||
| 1194 | 1441 | ||
| 1195 | $userid = $document->getModifiedUserId(); | 1442 | $userid = $document->getModifiedUserId(); |
| 1196 | if (is_numeric($userid)) | 1443 | if (is_numeric($userid)) |
| @@ -1202,6 +1449,7 @@ class KTAPI_Document extends KTAPI_FolderItem | @@ -1202,6 +1449,7 @@ class KTAPI_Document extends KTAPI_FolderItem | ||
| 1202 | { | 1449 | { |
| 1203 | $username='n/a'; | 1450 | $username='n/a'; |
| 1204 | } | 1451 | } |
| 1452 | + $detail['modified_by'] = $username; | ||
| 1205 | $detail['updated_by'] = $username; | 1453 | $detail['updated_by'] = $username; |
| 1206 | $detail['document_id'] = (int) $document->getId(); | 1454 | $detail['document_id'] = (int) $document->getId(); |
| 1207 | $detail['folder_id'] = (int) $document->getFolderID(); | 1455 | $detail['folder_id'] = (int) $document->getFolderID(); |
| @@ -1230,6 +1478,22 @@ class KTAPI_Document extends KTAPI_FolderItem | @@ -1230,6 +1478,22 @@ class KTAPI_Document extends KTAPI_FolderItem | ||
| 1230 | } | 1478 | } |
| 1231 | $detail['workflow_state']=$workflowstate; | 1479 | $detail['workflow_state']=$workflowstate; |
| 1232 | 1480 | ||
| 1481 | + $userid = $document->getOwnerID(); | ||
| 1482 | + | ||
| 1483 | + if (is_numeric($userid)) | ||
| 1484 | + { | ||
| 1485 | + $user = User::get($userid); | ||
| 1486 | + $username=(is_null($user) || PEAR::isError($user))?'* unknown *':$user->getName(); | ||
| 1487 | + } | ||
| 1488 | + else | ||
| 1489 | + { | ||
| 1490 | + $username = 'n/a'; | ||
| 1491 | + } | ||
| 1492 | + $detail['owner'] = $username; | ||
| 1493 | + | ||
| 1494 | + $detail['is_immutable'] = (bool) $document->getImmutable(); | ||
| 1495 | + | ||
| 1496 | + | ||
| 1233 | $userid = $document->getCheckedOutUserID(); | 1497 | $userid = $document->getCheckedOutUserID(); |
| 1234 | 1498 | ||
| 1235 | if (is_numeric($userid)) | 1499 | if (is_numeric($userid)) |
| @@ -1241,7 +1505,20 @@ class KTAPI_Document extends KTAPI_FolderItem | @@ -1241,7 +1505,20 @@ class KTAPI_Document extends KTAPI_FolderItem | ||
| 1241 | { | 1505 | { |
| 1242 | $username = 'n/a'; | 1506 | $username = 'n/a'; |
| 1243 | } | 1507 | } |
| 1244 | - $detail['checkout_by'] = $username; | 1508 | + $detail['checked_out_by'] = $username; |
| 1509 | + | ||
| 1510 | + list($major, $minor, $fix) = explode('.', $default->systemVersion); | ||
| 1511 | + | ||
| 1512 | + | ||
| 1513 | + if ($major == 3 && $minor >= 5) | ||
| 1514 | + { | ||
| 1515 | + $detail['checked_out_date'] = $document->getCheckedOutDate(); | ||
| 1516 | + } | ||
| 1517 | + else | ||
| 1518 | + { | ||
| 1519 | + $detail['checked_out_date'] = $detail['modified_date']; | ||
| 1520 | + } | ||
| 1521 | + if (is_null($detail['checked_out_date'])) $detail['checked_out_date'] = 'n/a'; | ||
| 1245 | 1522 | ||
| 1246 | $detail['full_path'] = $this->ktapi_folder->get_full_path() . '/' . $this->get_title(); | 1523 | $detail['full_path'] = $this->ktapi_folder->get_full_path() . '/' . $this->get_title(); |
| 1247 | 1524 |
ktapi/KTAPIFolder.inc.php
| @@ -61,7 +61,7 @@ class KTAPI_Folder extends KTAPI_FolderItem | @@ -61,7 +61,7 @@ class KTAPI_Folder extends KTAPI_FolderItem | ||
| 61 | * @param int $folderid | 61 | * @param int $folderid |
| 62 | * @return KTAPI_Folder | 62 | * @return KTAPI_Folder |
| 63 | */ | 63 | */ |
| 64 | - public static function &get(&$ktapi, $folderid) | 64 | + function &get(&$ktapi, $folderid) |
| 65 | { | 65 | { |
| 66 | assert(!is_null($ktapi)); | 66 | assert(!is_null($ktapi)); |
| 67 | assert(is_a($ktapi, 'KTAPI')); | 67 | assert(is_a($ktapi, 'KTAPI')); |
| @@ -93,7 +93,7 @@ class KTAPI_Folder extends KTAPI_FolderItem | @@ -93,7 +93,7 @@ class KTAPI_Folder extends KTAPI_FolderItem | ||
| 93 | * @param Folder $folder | 93 | * @param Folder $folder |
| 94 | * @return KTAPI_Folder | 94 | * @return KTAPI_Folder |
| 95 | */ | 95 | */ |
| 96 | - public function KTAPI_Folder(&$ktapi, &$folder) | 96 | + function KTAPI_Folder(&$ktapi, &$folder) |
| 97 | { | 97 | { |
| 98 | $this->ktapi = &$ktapi; | 98 | $this->ktapi = &$ktapi; |
| 99 | $this->folder = &$folder; | 99 | $this->folder = &$folder; |
| @@ -106,7 +106,7 @@ class KTAPI_Folder extends KTAPI_FolderItem | @@ -106,7 +106,7 @@ class KTAPI_Folder extends KTAPI_FolderItem | ||
| 106 | * @access protected | 106 | * @access protected |
| 107 | * @return Folder | 107 | * @return Folder |
| 108 | */ | 108 | */ |
| 109 | - public function &get_folder() | 109 | + function &get_folder() |
| 110 | { | 110 | { |
| 111 | return $this->folder; | 111 | return $this->folder; |
| 112 | } | 112 | } |
| @@ -117,7 +117,7 @@ class KTAPI_Folder extends KTAPI_FolderItem | @@ -117,7 +117,7 @@ class KTAPI_Folder extends KTAPI_FolderItem | ||
| 117 | * | 117 | * |
| 118 | * @return array | 118 | * @return array |
| 119 | */ | 119 | */ |
| 120 | - public function get_detail() | 120 | + function get_detail() |
| 121 | { | 121 | { |
| 122 | $detail = array( | 122 | $detail = array( |
| 123 | 'id'=>(int) $this->folderid, | 123 | 'id'=>(int) $this->folderid, |
| @@ -129,12 +129,12 @@ class KTAPI_Folder extends KTAPI_FolderItem | @@ -129,12 +129,12 @@ class KTAPI_Folder extends KTAPI_FolderItem | ||
| 129 | return $detail; | 129 | return $detail; |
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | - public function get_parent_folder_id() | 132 | + function get_parent_folder_id() |
| 133 | { | 133 | { |
| 134 | return (int) $this->folder->getParentID(); | 134 | return (int) $this->folder->getParentID(); |
| 135 | } | 135 | } |
| 136 | 136 | ||
| 137 | - public function get_folder_name() | 137 | + function get_folder_name() |
| 138 | { | 138 | { |
| 139 | return $this->folder->getFolderName($this->folderid); | 139 | return $this->folder->getFolderName($this->folderid); |
| 140 | } | 140 | } |
| @@ -145,12 +145,12 @@ class KTAPI_Folder extends KTAPI_FolderItem | @@ -145,12 +145,12 @@ class KTAPI_Folder extends KTAPI_FolderItem | ||
| 145 | * | 145 | * |
| 146 | * @return int | 146 | * @return int |
| 147 | */ | 147 | */ |
| 148 | - public function get_folderid() | 148 | + function get_folderid() |
| 149 | { | 149 | { |
| 150 | return (int) $this->folderid; | 150 | return (int) $this->folderid; |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | - public static function &_get_folder_by_name($ktapi, $foldername, $folderid) | 153 | + function &_get_folder_by_name($ktapi, $foldername, $folderid) |
| 154 | { | 154 | { |
| 155 | $foldername=trim($foldername); | 155 | $foldername=trim($foldername); |
| 156 | if (empty($foldername)) | 156 | if (empty($foldername)) |
| @@ -189,12 +189,12 @@ class KTAPI_Folder extends KTAPI_FolderItem | @@ -189,12 +189,12 @@ class KTAPI_Folder extends KTAPI_FolderItem | ||
| 189 | * @param string $foldername | 189 | * @param string $foldername |
| 190 | * @return KTAPI_Folder | 190 | * @return KTAPI_Folder |
| 191 | */ | 191 | */ |
| 192 | - public function &get_folder_by_name($foldername) | 192 | + function &get_folder_by_name($foldername) |
| 193 | { | 193 | { |
| 194 | return KTAPI_Folder::_get_folder_by_name($this->ktapi, $foldername, $this->folderid); | 194 | return KTAPI_Folder::_get_folder_by_name($this->ktapi, $foldername, $this->folderid); |
| 195 | } | 195 | } |
| 196 | 196 | ||
| 197 | - public function get_full_path() | 197 | + function get_full_path() |
| 198 | { | 198 | { |
| 199 | $path = $this->folder->getFullPath() . '/' . $this->folder->getName(); | 199 | $path = $this->folder->getFullPath() . '/' . $this->folder->getName(); |
| 200 | 200 | ||
| @@ -209,7 +209,7 @@ class KTAPI_Folder extends KTAPI_FolderItem | @@ -209,7 +209,7 @@ class KTAPI_Folder extends KTAPI_FolderItem | ||
| 209 | * @param string $function | 209 | * @param string $function |
| 210 | * @return KTAPI_Document | 210 | * @return KTAPI_Document |
| 211 | */ | 211 | */ |
| 212 | - public function &_get_document_by_name($documentname, $function='getByNameAndFolder') | 212 | + function &_get_document_by_name($documentname, $function='getByNameAndFolder') |
| 213 | { | 213 | { |
| 214 | $documentname=trim($documentname); | 214 | $documentname=trim($documentname); |
| 215 | if (empty($documentname)) | 215 | if (empty($documentname)) |
| @@ -272,7 +272,7 @@ class KTAPI_Folder extends KTAPI_FolderItem | @@ -272,7 +272,7 @@ class KTAPI_Folder extends KTAPI_FolderItem | ||
| 272 | * @param string $documentname | 272 | * @param string $documentname |
| 273 | * @return KTAPI_Document | 273 | * @return KTAPI_Document |
| 274 | */ | 274 | */ |
| 275 | - public function &get_document_by_name($documentname) | 275 | + function &get_document_by_name($documentname) |
| 276 | { | 276 | { |
| 277 | return $this->_get_document_by_name($documentname,'getByNameAndFolder'); | 277 | return $this->_get_document_by_name($documentname,'getByNameAndFolder'); |
| 278 | } | 278 | } |
| @@ -284,12 +284,12 @@ class KTAPI_Folder extends KTAPI_FolderItem | @@ -284,12 +284,12 @@ class KTAPI_Folder extends KTAPI_FolderItem | ||
| 284 | * @param string $documentname | 284 | * @param string $documentname |
| 285 | * @return KTAPI_Document | 285 | * @return KTAPI_Document |
| 286 | */ | 286 | */ |
| 287 | - public function &get_document_by_filename($documentname) | 287 | + function &get_document_by_filename($documentname) |
| 288 | { | 288 | { |
| 289 | return $this->_get_document_by_name($documentname,'getByFilenameAndFolder'); | 289 | return $this->_get_document_by_name($documentname,'getByFilenameAndFolder'); |
| 290 | } | 290 | } |
| 291 | 291 | ||
| 292 | - public function _resolve_user($userid) | 292 | + function _resolve_user($userid) |
| 293 | { | 293 | { |
| 294 | $user=null; | 294 | $user=null; |
| 295 | 295 | ||
| @@ -304,7 +304,7 @@ class KTAPI_Folder extends KTAPI_FolderItem | @@ -304,7 +304,7 @@ class KTAPI_Folder extends KTAPI_FolderItem | ||
| 304 | return $user; | 304 | return $user; |
| 305 | } | 305 | } |
| 306 | 306 | ||
| 307 | - public function get_listing($depth=1, $what='DF') | 307 | + function get_listing($depth=1, $what='DF') |
| 308 | { | 308 | { |
| 309 | if ($depth < 1) | 309 | if ($depth < 1) |
| 310 | { | 310 | { |
| @@ -456,7 +456,7 @@ class KTAPI_Folder extends KTAPI_FolderItem | @@ -456,7 +456,7 @@ class KTAPI_Folder extends KTAPI_FolderItem | ||
| 456 | * @param string $tempfilename This is a reference to the file that is accessible locally on the file system. | 456 | * @param string $tempfilename This is a reference to the file that is accessible locally on the file system. |
| 457 | * @return KTAPI_Document | 457 | * @return KTAPI_Document |
| 458 | */ | 458 | */ |
| 459 | - public function &add_document($title, $filename, $documenttype, $tempfilename) | 459 | + function &add_document($title, $filename, $documenttype, $tempfilename) |
| 460 | { | 460 | { |
| 461 | if (!is_file($tempfilename)) | 461 | if (!is_file($tempfilename)) |
| 462 | { | 462 | { |
| @@ -514,7 +514,7 @@ class KTAPI_Folder extends KTAPI_FolderItem | @@ -514,7 +514,7 @@ class KTAPI_Folder extends KTAPI_FolderItem | ||
| 514 | * @param string $foldername | 514 | * @param string $foldername |
| 515 | * @return KTAPI_Folder | 515 | * @return KTAPI_Folder |
| 516 | */ | 516 | */ |
| 517 | - public function &add_folder($foldername) | 517 | + function &add_folder($foldername) |
| 518 | { | 518 | { |
| 519 | $user = $this->can_user_access_object_requiring_permission($this->folder, KTAPI_PERMISSION_ADD_FOLDER); | 519 | $user = $this->can_user_access_object_requiring_permission($this->folder, KTAPI_PERMISSION_ADD_FOLDER); |
| 520 | 520 | ||
| @@ -542,7 +542,7 @@ class KTAPI_Folder extends KTAPI_FolderItem | @@ -542,7 +542,7 @@ class KTAPI_Folder extends KTAPI_FolderItem | ||
| 542 | * | 542 | * |
| 543 | * @param string $reason | 543 | * @param string $reason |
| 544 | */ | 544 | */ |
| 545 | - public function delete($reason) | 545 | + function delete($reason) |
| 546 | { | 546 | { |
| 547 | $user = $this->can_user_access_object_requiring_permission($this->folder, KTAPI_PERMISSION_DELETE); | 547 | $user = $this->can_user_access_object_requiring_permission($this->folder, KTAPI_PERMISSION_DELETE); |
| 548 | if (PEAR::isError($user)) | 548 | if (PEAR::isError($user)) |
| @@ -571,7 +571,7 @@ class KTAPI_Folder extends KTAPI_FolderItem | @@ -571,7 +571,7 @@ class KTAPI_Folder extends KTAPI_FolderItem | ||
| 571 | * | 571 | * |
| 572 | * @param string $newname | 572 | * @param string $newname |
| 573 | */ | 573 | */ |
| 574 | - public function rename($newname) | 574 | + function rename($newname) |
| 575 | { | 575 | { |
| 576 | $user = $this->can_user_access_object_requiring_permission($this->folder, KTAPI_PERMISSION_RENAME_FOLDER); | 576 | $user = $this->can_user_access_object_requiring_permission($this->folder, KTAPI_PERMISSION_RENAME_FOLDER); |
| 577 | if (PEAR::isError($user)) | 577 | if (PEAR::isError($user)) |
| @@ -596,7 +596,7 @@ class KTAPI_Folder extends KTAPI_FolderItem | @@ -596,7 +596,7 @@ class KTAPI_Folder extends KTAPI_FolderItem | ||
| 596 | * @param KTAPI_Folder $ktapi_target_folder | 596 | * @param KTAPI_Folder $ktapi_target_folder |
| 597 | * @param string $reason | 597 | * @param string $reason |
| 598 | */ | 598 | */ |
| 599 | - public function move($ktapi_target_folder, $reason='') | 599 | + function move($ktapi_target_folder, $reason='') |
| 600 | { | 600 | { |
| 601 | assert(!is_null($ktapi_target_folder)); | 601 | assert(!is_null($ktapi_target_folder)); |
| 602 | assert(is_a($ktapi_target_folder,'KTAPI_Folder')); | 602 | assert(is_a($ktapi_target_folder,'KTAPI_Folder')); |
| @@ -628,7 +628,7 @@ class KTAPI_Folder extends KTAPI_FolderItem | @@ -628,7 +628,7 @@ class KTAPI_Folder extends KTAPI_FolderItem | ||
| 628 | * @param KTAPI_Folder $ktapi_target_folder | 628 | * @param KTAPI_Folder $ktapi_target_folder |
| 629 | * @param string $reason | 629 | * @param string $reason |
| 630 | */ | 630 | */ |
| 631 | - public function copy($ktapi_target_folder, $reason='') | 631 | + function copy($ktapi_target_folder, $reason='') |
| 632 | { | 632 | { |
| 633 | assert(!is_null($ktapi_target_folder)); | 633 | assert(!is_null($ktapi_target_folder)); |
| 634 | assert(is_a($ktapi_target_folder,'KTAPI_Folder')); | 634 | assert(is_a($ktapi_target_folder,'KTAPI_Folder')); |
| @@ -661,7 +661,7 @@ class KTAPI_Folder extends KTAPI_FolderItem | @@ -661,7 +661,7 @@ class KTAPI_Folder extends KTAPI_FolderItem | ||
| 661 | * @access public | 661 | * @access public |
| 662 | * @return array | 662 | * @return array |
| 663 | */ | 663 | */ |
| 664 | - public function get_permissions() | 664 | + function get_permissions() |
| 665 | { | 665 | { |
| 666 | return new PEAR_Error('TODO'); | 666 | return new PEAR_Error('TODO'); |
| 667 | } | 667 | } |
| @@ -672,7 +672,7 @@ class KTAPI_Folder extends KTAPI_FolderItem | @@ -672,7 +672,7 @@ class KTAPI_Folder extends KTAPI_FolderItem | ||
| 672 | * @access public | 672 | * @access public |
| 673 | * @return array | 673 | * @return array |
| 674 | */ | 674 | */ |
| 675 | - public function get_transaction_history() | 675 | + function get_transaction_history() |
| 676 | { | 676 | { |
| 677 | return new PEAR_Error('TODO'); | 677 | return new PEAR_Error('TODO'); |
| 678 | } | 678 | } |
ktapi/KTAPISession.inc.php
| @@ -36,7 +36,7 @@ | @@ -36,7 +36,7 @@ | ||
| 36 | * | 36 | * |
| 37 | */ | 37 | */ |
| 38 | 38 | ||
| 39 | -abstract class KTAPI_Session | 39 | +class KTAPI_Session |
| 40 | { | 40 | { |
| 41 | var $ktapi; | 41 | var $ktapi; |
| 42 | var $user = null; | 42 | var $user = null; |
| @@ -45,7 +45,7 @@ abstract class KTAPI_Session | @@ -45,7 +45,7 @@ abstract class KTAPI_Session | ||
| 45 | var $active; | 45 | var $active; |
| 46 | var $origUserId; | 46 | var $origUserId; |
| 47 | 47 | ||
| 48 | - public function KTAPI_Session(&$ktapi, &$user) | 48 | + function KTAPI_Session(&$ktapi, &$user) |
| 49 | { | 49 | { |
| 50 | assert(!is_null($ktapi)); | 50 | assert(!is_null($ktapi)); |
| 51 | assert(is_a($ktapi,'KTAPI')); | 51 | assert(is_a($ktapi,'KTAPI')); |
| @@ -64,7 +64,7 @@ abstract class KTAPI_Session | @@ -64,7 +64,7 @@ abstract class KTAPI_Session | ||
| 64 | * | 64 | * |
| 65 | * @return string | 65 | * @return string |
| 66 | */ | 66 | */ |
| 67 | - public function get_session() | 67 | + function get_session() |
| 68 | { | 68 | { |
| 69 | return $this->session; | 69 | return $this->session; |
| 70 | } | 70 | } |
| @@ -74,7 +74,7 @@ abstract class KTAPI_Session | @@ -74,7 +74,7 @@ abstract class KTAPI_Session | ||
| 74 | * | 74 | * |
| 75 | * @return int | 75 | * @return int |
| 76 | */ | 76 | */ |
| 77 | - public function get_sessionid() | 77 | + function get_sessionid() |
| 78 | { | 78 | { |
| 79 | return $this->sessionid; | 79 | return $this->sessionid; |
| 80 | } | 80 | } |
| @@ -84,19 +84,19 @@ abstract class KTAPI_Session | @@ -84,19 +84,19 @@ abstract class KTAPI_Session | ||
| 84 | * | 84 | * |
| 85 | * @return User | 85 | * @return User |
| 86 | */ | 86 | */ |
| 87 | - public function &get_user() | 87 | + function &get_user() |
| 88 | { | 88 | { |
| 89 | return $this->user; | 89 | return $this->user; |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | - public function logout() | 92 | + function logout() |
| 93 | { | 93 | { |
| 94 | $_SESSION['userID'] = $this->origUserId; | 94 | $_SESSION['userID'] = $this->origUserId; |
| 95 | $this->active=false; | 95 | $this->active=false; |
| 96 | // don't need to do anything really | 96 | // don't need to do anything really |
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | - public function is_active() | 99 | + function is_active() |
| 100 | { | 100 | { |
| 101 | return $this->active; | 101 | return $this->active; |
| 102 | } | 102 | } |
| @@ -107,7 +107,7 @@ class KTAPI_UserSession extends KTAPI_Session | @@ -107,7 +107,7 @@ class KTAPI_UserSession extends KTAPI_Session | ||
| 107 | { | 107 | { |
| 108 | var $ip = null; | 108 | var $ip = null; |
| 109 | 109 | ||
| 110 | - public function KTAPI_UserSession(&$ktapi, &$user, $session, $sessionid, $ip) | 110 | + function KTAPI_UserSession(&$ktapi, &$user, $session, $sessionid, $ip) |
| 111 | { | 111 | { |
| 112 | parent::KTAPI_Session($ktapi, $user); | 112 | parent::KTAPI_Session($ktapi, $user); |
| 113 | 113 | ||
| @@ -133,7 +133,7 @@ class KTAPI_UserSession extends KTAPI_Session | @@ -133,7 +133,7 @@ class KTAPI_UserSession extends KTAPI_Session | ||
| 133 | * @access private | 133 | * @access private |
| 134 | * @return string | 134 | * @return string |
| 135 | */ | 135 | */ |
| 136 | - public function resolveIP() | 136 | + function resolveIP() |
| 137 | { | 137 | { |
| 138 | if (getenv("REMOTE_ADDR")) | 138 | if (getenv("REMOTE_ADDR")) |
| 139 | { | 139 | { |
| @@ -163,7 +163,7 @@ class KTAPI_UserSession extends KTAPI_Session | @@ -163,7 +163,7 @@ class KTAPI_UserSession extends KTAPI_Session | ||
| 163 | * @static | 163 | * @static |
| 164 | * @param User $user | 164 | * @param User $user |
| 165 | */ | 165 | */ |
| 166 | - private function _check_session(&$user) | 166 | + function _check_session(&$user) |
| 167 | { | 167 | { |
| 168 | $user_id = $user->getId(); | 168 | $user_id = $user->getId(); |
| 169 | 169 | ||
| @@ -218,7 +218,7 @@ class KTAPI_UserSession extends KTAPI_Session | @@ -218,7 +218,7 @@ class KTAPI_UserSession extends KTAPI_Session | ||
| 218 | * @param string $password | 218 | * @param string $password |
| 219 | * @return KTAPI_Session | 219 | * @return KTAPI_Session |
| 220 | */ | 220 | */ |
| 221 | - public function &start_session(&$ktapi, $username, $password, $ip=null) | 221 | + function &start_session(&$ktapi, $username, $password, $ip=null) |
| 222 | { | 222 | { |
| 223 | $this->active=false; | 223 | $this->active=false; |
| 224 | if ( empty($username) ) | 224 | if ( empty($username) ) |
| @@ -272,7 +272,7 @@ class KTAPI_UserSession extends KTAPI_Session | @@ -272,7 +272,7 @@ class KTAPI_UserSession extends KTAPI_Session | ||
| 272 | * @param string $ip | 272 | * @param string $ip |
| 273 | * @return KTAPI_Session | 273 | * @return KTAPI_Session |
| 274 | */ | 274 | */ |
| 275 | - public function &get_active_session(&$ktapi, $session, $ip) | 275 | + function &get_active_session(&$ktapi, $session, $ip) |
| 276 | { | 276 | { |
| 277 | $sql = "SELECT id, user_id FROM active_sessions WHERE session_id='$session'"; | 277 | $sql = "SELECT id, user_id FROM active_sessions WHERE session_id='$session'"; |
| 278 | if (!empty($ip)) | 278 | if (!empty($ip)) |
| @@ -313,7 +313,7 @@ class KTAPI_UserSession extends KTAPI_Session | @@ -313,7 +313,7 @@ class KTAPI_UserSession extends KTAPI_Session | ||
| 313 | * This closes the current session. | 313 | * This closes the current session. |
| 314 | * | 314 | * |
| 315 | */ | 315 | */ |
| 316 | - public function logout() | 316 | + function logout() |
| 317 | { | 317 | { |
| 318 | $sql = "DELETE FROM active_sessions WHERE id=$this->sessionid"; | 318 | $sql = "DELETE FROM active_sessions WHERE id=$this->sessionid"; |
| 319 | $result = DBUtil::runQuery($sql); | 319 | $result = DBUtil::runQuery($sql); |
| @@ -332,7 +332,7 @@ class KTAPI_UserSession extends KTAPI_Session | @@ -332,7 +332,7 @@ class KTAPI_UserSession extends KTAPI_Session | ||
| 332 | 332 | ||
| 333 | class KTAPI_AnonymousSession extends KTAPI_UserSession | 333 | class KTAPI_AnonymousSession extends KTAPI_UserSession |
| 334 | { | 334 | { |
| 335 | - public function &start_session(&$ktapi, $ip=null) | 335 | + function &start_session(&$ktapi, $ip=null) |
| 336 | { | 336 | { |
| 337 | $user =& User::get(-2); | 337 | $user =& User::get(-2); |
| 338 | if (is_null($user) || PEAR::isError($user) || ($user === false) || !$user->isAnonymous()) | 338 | if (is_null($user) || PEAR::isError($user) || ($user === false) || !$user->isAnonymous()) |
| @@ -370,7 +370,7 @@ class KTAPI_AnonymousSession extends KTAPI_UserSession | @@ -370,7 +370,7 @@ class KTAPI_AnonymousSession extends KTAPI_UserSession | ||
| 370 | 370 | ||
| 371 | class KTAPI_SystemSession extends KTAPI_Session | 371 | class KTAPI_SystemSession extends KTAPI_Session |
| 372 | { | 372 | { |
| 373 | - public function KTAPI_SystemSession(&$ktapi, &$user) | 373 | + function KTAPI_SystemSession(&$ktapi, &$user) |
| 374 | { | 374 | { |
| 375 | parent::KTAPI_Session($ktapi, $user); | 375 | parent::KTAPI_Session($ktapi, $user); |
| 376 | $this->active=true; | 376 | $this->active=true; |
ktwebdav/lib/KTWebDAVServer.inc.php
| @@ -1132,9 +1132,10 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | @@ -1132,9 +1132,10 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | ||
| 1132 | 1132 | ||
| 1133 | /** | 1133 | /** |
| 1134 | * GET method helper | 1134 | * GET method helper |
| 1135 | + * Method takes a directory path and checks whether it refers to a document or folder. The relevant folder and/or document id is returned. | ||
| 1135 | * | 1136 | * |
| 1136 | - * @param string directory path | ||
| 1137 | - * @return array or false | 1137 | + * @param $path string The directory path |
| 1138 | + * @return array or bool Either returns an array of folder/document id's or false if an error occurred | ||
| 1138 | */ | 1139 | */ |
| 1139 | function _folderOrDocument($path) { | 1140 | function _folderOrDocument($path) { |
| 1140 | 1141 | ||
| @@ -1142,14 +1143,14 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | @@ -1142,14 +1143,14 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | ||
| 1142 | 1143 | ||
| 1143 | $this->ktwebdavLog("Entering _folderOrDocument. path is " . $path, 'info', true); | 1144 | $this->ktwebdavLog("Entering _folderOrDocument. path is " . $path, 'info', true); |
| 1144 | 1145 | ||
| 1145 | - if ( !(strstr($path,"__BAOBABCLIENT__") === false) ) { | ||
| 1146 | - return array(0, 1); | ||
| 1147 | - } | ||
| 1148 | - | 1146 | + /* ** Get the directory path and the folder/document being acted on ** */ |
| 1149 | $sFileName = basename($path); | 1147 | $sFileName = basename($path); |
| 1150 | // for windows replace backslash with forwardslash | 1148 | // for windows replace backslash with forwardslash |
| 1151 | $sFolderPath = str_replace("\\", '/', dirname($path) ); | 1149 | $sFolderPath = str_replace("\\", '/', dirname($path) ); |
| 1152 | 1150 | ||
| 1151 | + /* ** Get the starting point for recursing through the directory structure | ||
| 1152 | + FolderId = 0 if we're in the root folder | ||
| 1153 | + FolderId = 1 the starting point for locating any other folder ** */ | ||
| 1153 | if ($sFolderPath == "/" || $sFolderPath == "/ktwebdav") { | 1154 | if ($sFolderPath == "/" || $sFolderPath == "/ktwebdav") { |
| 1154 | $this->ktwebdavLog("This is the root folder.", 'info', true); | 1155 | $this->ktwebdavLog("This is the root folder.", 'info', true); |
| 1155 | $sFolderPath = $this->rootFolder; | 1156 | $sFolderPath = $this->rootFolder; |
| @@ -1164,6 +1165,9 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | @@ -1164,6 +1165,9 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | ||
| 1164 | $this->ktwebdavLog("sFolderName is " . $sFolderPath, 'info', true); | 1165 | $this->ktwebdavLog("sFolderName is " . $sFolderPath, 'info', true); |
| 1165 | $this->ktwebdavLog("iFolderID is " . $iFolderID, 'info', true); | 1166 | $this->ktwebdavLog("iFolderID is " . $iFolderID, 'info', true); |
| 1166 | 1167 | ||
| 1168 | + /* ** Break up the directory path into its component directory's, | ||
| 1169 | + recurse through the directory's to find the correct id of the current directory. | ||
| 1170 | + Avoids situations where several directory's have the same name. ** */ | ||
| 1167 | $aFolderNames = split('/', $sFolderPath); | 1171 | $aFolderNames = split('/', $sFolderPath); |
| 1168 | 1172 | ||
| 1169 | $this->ktwebdavLog("aFolderNames are: " . print_r($aFolderNames, true), 'info', true); | 1173 | $this->ktwebdavLog("aFolderNames are: " . print_r($aFolderNames, true), 'info', true); |
| @@ -1196,6 +1200,9 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | @@ -1196,6 +1200,9 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | ||
| 1196 | $this->ktwebdavLog("iFolderID set to " . $iFolderID, 'info', true); | 1200 | $this->ktwebdavLog("iFolderID set to " . $iFolderID, 'info', true); |
| 1197 | } | 1201 | } |
| 1198 | 1202 | ||
| 1203 | + /* ** Get the document id using the basename and parent folder id as parameters. | ||
| 1204 | + If an id is obtained then the path refers to a document. | ||
| 1205 | + If no id is returned then the path refers to a folder or a non-existing document. ** */ | ||
| 1199 | // FIXME: Direct database access | 1206 | // FIXME: Direct database access |
| 1200 | // $sQuery = "SELECT id FROM documents WHERE folder_id = ? AND filename = ? AND status_id = 1"; | 1207 | // $sQuery = "SELECT id FROM documents WHERE folder_id = ? AND filename = ? AND status_id = 1"; |
| 1201 | $sQuery = "SELECT D.id "; | 1208 | $sQuery = "SELECT D.id "; |
| @@ -1214,12 +1221,18 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | @@ -1214,12 +1221,18 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | ||
| 1214 | return false; | 1221 | return false; |
| 1215 | } | 1222 | } |
| 1216 | 1223 | ||
| 1224 | + /* ** If the path refers to a folder or a non-existing document, | ||
| 1225 | + Get the folder id using the basename and parent folder id as parameters. | ||
| 1226 | + If an id is obtained then the path refers to an existing folder. | ||
| 1227 | + If no id is returned and the basename is empty then path refers to the root folder. | ||
| 1228 | + If no id is returned and the basename is not empty, then the path refers to either a non-existing folder or document. ** */ | ||
| 1217 | if ($iDocumentID === null) { | 1229 | if ($iDocumentID === null) { |
| 1218 | $this->ktwebdavLog("iDocumentID is null", 'info', true); | 1230 | $this->ktwebdavLog("iDocumentID is null", 'info', true); |
| 1219 | // FIXME: Direct database access | 1231 | // FIXME: Direct database access |
| 1220 | $sQuery = "SELECT id FROM folders WHERE parent_id = ? AND name = ?"; | 1232 | $sQuery = "SELECT id FROM folders WHERE parent_id = ? AND name = ?"; |
| 1221 | $aParams = array($iFolderID, $sFileName); | 1233 | $aParams = array($iFolderID, $sFileName); |
| 1222 | $id = DBUtil::getOneResultKey(array($sQuery, $aParams), 'id'); | 1234 | $id = DBUtil::getOneResultKey(array($sQuery, $aParams), 'id'); |
| 1235 | + | ||
| 1223 | if (PEAR::isError($id)) { | 1236 | if (PEAR::isError($id)) { |
| 1224 | $this->ktwebdavLog("A DB(2) error occurred in _folderOrDocument", 'info', true); | 1237 | $this->ktwebdavLog("A DB(2) error occurred in _folderOrDocument", 'info', true); |
| 1225 | return false; | 1238 | return false; |
| @@ -1235,6 +1248,7 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | @@ -1235,6 +1248,7 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | ||
| 1235 | $this->ktwebdavLog("Setting Location Header to " . "Location: " . $_SERVER["PHP_SELF"] . "/", 'info', true); | 1248 | $this->ktwebdavLog("Setting Location Header to " . "Location: " . $_SERVER["PHP_SELF"] . "/", 'info', true); |
| 1236 | header("Location: " . $_SERVER["PHP_SELF"] . "/"); | 1249 | header("Location: " . $_SERVER["PHP_SELF"] . "/"); |
| 1237 | } | 1250 | } |
| 1251 | + $this->ktwebdavLog("DEBUG: return id ".$id, 'info', true); | ||
| 1238 | return array($id, null); | 1252 | return array($id, null); |
| 1239 | } | 1253 | } |
| 1240 | 1254 | ||
| @@ -1647,24 +1661,16 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | @@ -1647,24 +1661,16 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | ||
| 1647 | 1661 | ||
| 1648 | /** | 1662 | /** |
| 1649 | * MOVE method handler | 1663 | * MOVE method handler |
| 1664 | + * Method checks if the source path refers to a document / folder then calls the appropriate method handler. | ||
| 1650 | * | 1665 | * |
| 1651 | - * @param array parameter passing array | 1666 | + * @param $options array parameter passing array |
| 1652 | * @return string HTTP status code or false | 1667 | * @return string HTTP status code or false |
| 1653 | */ | 1668 | */ |
| 1654 | function MOVE($options) | 1669 | function MOVE($options) |
| 1655 | { | 1670 | { |
| 1656 | - // Use the WebDAV standards way. | ||
| 1657 | - // See rfc2518 Section 8.9 | ||
| 1658 | - // This does a copy with delete | ||
| 1659 | - // FIXME: This way does not retain document history and other info | ||
| 1660 | - | ||
| 1661 | - //return $this->COPY($options, true); | ||
| 1662 | - | ||
| 1663 | - // Use the KT way. | ||
| 1664 | - // FIXME: This way does not allow overwrite | ||
| 1665 | - | ||
| 1666 | $this->ktwebdavLog("Entering MOVE. options are " . print_r($options, true), 'info', true); | 1671 | $this->ktwebdavLog("Entering MOVE. options are " . print_r($options, true), 'info', true); |
| 1667 | 1672 | ||
| 1673 | + /* ** Check that write is allowed ** */ | ||
| 1668 | if ($this->checkSafeMode()) { | 1674 | if ($this->checkSafeMode()) { |
| 1669 | 1675 | ||
| 1670 | if (!empty($_SERVER["CONTENT_LENGTH"])) { // no body parsing yet | 1676 | if (!empty($_SERVER["CONTENT_LENGTH"])) { // no body parsing yet |
| @@ -1679,6 +1685,9 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | @@ -1679,6 +1685,9 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | ||
| 1679 | } | 1685 | } |
| 1680 | */ | 1686 | */ |
| 1681 | 1687 | ||
| 1688 | + /* ** Get the path to the document/folder to be copied. | ||
| 1689 | + Call function to check if the path refers to a document or a folder. | ||
| 1690 | + Return 404 error if the path is invalid. ** */ | ||
| 1682 | $source_path = $options["path"]; | 1691 | $source_path = $options["path"]; |
| 1683 | 1692 | ||
| 1684 | // Fix for Mac Goliath | 1693 | // Fix for Mac Goliath |
| @@ -1710,22 +1719,30 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | @@ -1710,22 +1719,30 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | ||
| 1710 | return "404 Not found - Document was not found."; | 1719 | return "404 Not found - Document was not found."; |
| 1711 | } | 1720 | } |
| 1712 | 1721 | ||
| 1722 | + /* ** Get the returned parent folder id and document/folder id. | ||
| 1723 | + If the parent folder id is false, return 404 error. | ||
| 1724 | + If the document id is either false or null, then the source is a folder. | ||
| 1725 | + If the document id exists then the source is a document. | ||
| 1726 | + If the source is a folder then call _MOVEFolder. | ||
| 1727 | + If the source is a document then check if its checked out and call _MOVEDocument. ** */ | ||
| 1713 | list($iFolderID, $iDocumentID) = $source_res; | 1728 | list($iFolderID, $iDocumentID) = $source_res; |
| 1714 | - if ($iDocumentID === false) { | 1729 | + if ($iFolderID === false && ($iDocumentID === false || is_null($iDocumentID))) { |
| 1715 | $this->ktwebdavLog("404 Not found - Folder was not found.", 'info', true); | 1730 | $this->ktwebdavLog("404 Not found - Folder was not found.", 'info', true); |
| 1716 | return "404 Not found - Folder was not found."; | 1731 | return "404 Not found - Folder was not found."; |
| 1717 | } | 1732 | } |
| 1718 | 1733 | ||
| 1719 | - if (is_null($iDocumentID)) { | 1734 | + if (is_null($iDocumentID) || $iDocumentID === false) { |
| 1720 | // Source is a folder | 1735 | // Source is a folder |
| 1736 | + $this->ktwebdavLog("Source is a Folder.", 'info', true); | ||
| 1721 | $movestat = $this->_MOVEFolder($options, $iFolderID); | 1737 | $movestat = $this->_MOVEFolder($options, $iFolderID); |
| 1722 | 1738 | ||
| 1723 | } else { | 1739 | } else { |
| 1724 | // Source is a document | 1740 | // Source is a document |
| 1741 | + $this->ktwebdavLog("Source is a Document.", 'info', true); | ||
| 1725 | if ($this->canCopyMoveRenameDocument($iDocumentID)) { | 1742 | if ($this->canCopyMoveRenameDocument($iDocumentID)) { |
| 1726 | $movestat = $this->_MOVEDocument($options, $iFolderID, $iDocumentID); | 1743 | $movestat = $this->_MOVEDocument($options, $iFolderID, $iDocumentID); |
| 1727 | } else { | 1744 | } else { |
| 1728 | - return "Cannot MOVE document because it is checked out by another user."; | 1745 | + return "423 Locked - Cannot MOVE document because it is checked out by another user."; |
| 1729 | } | 1746 | } |
| 1730 | } | 1747 | } |
| 1731 | 1748 | ||
| @@ -1746,7 +1763,9 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | @@ -1746,7 +1763,9 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | ||
| 1746 | */ | 1763 | */ |
| 1747 | function _MOVEDocument($options, $iFolderID, $iDocumentID) { | 1764 | function _MOVEDocument($options, $iFolderID, $iDocumentID) { |
| 1748 | 1765 | ||
| 1766 | + /* ** Ensure that the destination path exists ** */ | ||
| 1749 | if ($options['dest'] == '') $options["dest"] = substr($options["dest_url"], strlen($_SERVER["SCRIPT_NAME"])); | 1767 | if ($options['dest'] == '') $options["dest"] = substr($options["dest_url"], strlen($_SERVER["SCRIPT_NAME"])); |
| 1768 | + $this->ktwebdavLog("Entering _MOVEDocument. options are " . print_r($options, true), 'info', true); | ||
| 1750 | 1769 | ||
| 1751 | // Fix for Mac Goliath | 1770 | // Fix for Mac Goliath |
| 1752 | // Modified - 25/10/07 - remove ktwebdav from document path | 1771 | // Modified - 25/10/07 - remove ktwebdav from document path |
| @@ -1760,11 +1779,11 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | @@ -1760,11 +1779,11 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | ||
| 1760 | } | 1779 | } |
| 1761 | } | 1780 | } |
| 1762 | 1781 | ||
| 1763 | - $this->ktwebdavLog("Entering _MOVEDocument. options are " . print_r($options, true), 'info', true); | ||
| 1764 | global $default; | 1782 | global $default; |
| 1765 | $new = true; | 1783 | $new = true; |
| 1766 | - //FIXME: refactor me into KTDocumentUtil | ||
| 1767 | 1784 | ||
| 1785 | + /* ** Get the relevant paths. Get the basename of the destination path as the destination filename. | ||
| 1786 | + Check whether the destination path refers to a folder / document. ** */ | ||
| 1768 | $oDocument = Document::get($iDocumentID); | 1787 | $oDocument = Document::get($iDocumentID); |
| 1769 | $oSrcFolder = Folder::get($iFolderID); | 1788 | $oSrcFolder = Folder::get($iFolderID); |
| 1770 | $oUser =& User::get($this->userID); | 1789 | $oUser =& User::get($this->userID); |
| @@ -1772,36 +1791,16 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | @@ -1772,36 +1791,16 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | ||
| 1772 | $source_path = $options["path"]; | 1791 | $source_path = $options["path"]; |
| 1773 | $dest_path = urldecode($options["dest"]); | 1792 | $dest_path = urldecode($options["dest"]); |
| 1774 | 1793 | ||
| 1775 | - // Is this a rename? | ||
| 1776 | - if (dirname($source_path) == dirname($dest_path)) { | ||
| 1777 | - // This is a rename | ||
| 1778 | - //if ($options['overwrite'] != 'T') { | ||
| 1779 | - // $this->ktwebdavLog("This is a Rename. Overwrite needs to be TRUE.", 'info', true); | ||
| 1780 | - // return "412 Precondition Failed - This is a Rename. Overwrite needs to be TRUE."; | ||
| 1781 | - //} | ||
| 1782 | - $this->ktwebdavLog("Got an oDocument of " . print_r($oDocument, true), 'info', true); | ||
| 1783 | - $this->ktwebdavLog("Got a new name of " . basename($dest_path), 'info', true); | ||
| 1784 | - | ||
| 1785 | - // Check if the user has permissions to write this document | ||
| 1786 | - $oPerm =& KTPermission::getByName('ktcore.permissions.write'); | ||
| 1787 | - $oUser =& User::get($this->userID); | ||
| 1788 | - if (!KTPermissionUtil::userHasPermissionOnItem($oUser, $oPerm, $oDocument)) { | ||
| 1789 | - return "403 Forbidden - User does not have sufficient permissions"; | ||
| 1790 | - } | ||
| 1791 | - $res = KTDocumentUtil::rename($oDocument, basename($dest_path), $oUser); | ||
| 1792 | - if (PEAR::isError($res) || is_null($res) || ($res === false)) { | ||
| 1793 | - return "404 Not Found - " . $res->getMessage(); | ||
| 1794 | - } else { | ||
| 1795 | - $this->ktwebdavLog("201 Created", 'info', true); | ||
| 1796 | - return "201 Created"; | ||
| 1797 | - } | ||
| 1798 | - | ||
| 1799 | - } | ||
| 1800 | - | 1794 | + /* ** Get the source folder object. |
| 1795 | + If the destination document is null, then the destination is a folder, continue. | ||
| 1796 | + If the destination document returns an id, then the document exists. Check overwrite. | ||
| 1797 | + If overwrite is true, then check permissions and delete the document, continue. | ||
| 1798 | + If the destination document is false, then continue. ** */ | ||
| 1801 | list($iDestFolder, $iDestDoc) = $this->_folderOrDocument($dest_path); | 1799 | list($iDestFolder, $iDestDoc) = $this->_folderOrDocument($dest_path); |
| 1802 | 1800 | ||
| 1803 | if (is_null($iDestDoc)) { | 1801 | if (is_null($iDestDoc)) { |
| 1804 | // the dest is a folder | 1802 | // the dest is a folder |
| 1803 | + $this->ktwebdavLog("Destination is a folder.", 'info', true); | ||
| 1805 | } else if ($iDestDoc !== false) { | 1804 | } else if ($iDestDoc !== false) { |
| 1806 | // Document exists | 1805 | // Document exists |
| 1807 | $this->ktwebdavLog("Destination Document exists.", 'info', true); | 1806 | $this->ktwebdavLog("Destination Document exists.", 'info', true); |
| @@ -1822,6 +1821,39 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | @@ -1822,6 +1821,39 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | ||
| 1822 | $new = false; | 1821 | $new = false; |
| 1823 | } | 1822 | } |
| 1824 | 1823 | ||
| 1824 | + /* ** Check if the source and destination directories are the same and the destination is not a folder. | ||
| 1825 | + Then action is probably a rename. | ||
| 1826 | + Check if user has permission to write to the document and folder. | ||
| 1827 | + Rename the document. ** */ | ||
| 1828 | + if ((dirname($source_path) == dirname($dest_path)) && !is_null($iDestDoc)) { | ||
| 1829 | + // This is a rename | ||
| 1830 | + $this->ktwebdavLog("This is a rename.", 'info', true); | ||
| 1831 | + $this->ktwebdavLog("Got an oDocument of " . print_r($oDocument, true), 'info', true); | ||
| 1832 | + $this->ktwebdavLog("Got a new name of " . basename($dest_path), 'info', true); | ||
| 1833 | + | ||
| 1834 | + // Check if the user has permissions to write this document | ||
| 1835 | + $oPerm =& KTPermission::getByName('ktcore.permissions.write'); | ||
| 1836 | + $oUser =& User::get($this->userID); | ||
| 1837 | + if (!KTPermissionUtil::userHasPermissionOnItem($oUser, $oPerm, $oDocument)) { | ||
| 1838 | + return "403 Forbidden - User does not have sufficient permissions"; | ||
| 1839 | + } | ||
| 1840 | + | ||
| 1841 | + // Perform rename | ||
| 1842 | + $res = KTDocumentUtil::rename($oDocument, basename($dest_path), $oUser); | ||
| 1843 | + if (PEAR::isError($res) || is_null($res) || ($res === false)) { | ||
| 1844 | + return "404 Not Found - " . $res->getMessage(); | ||
| 1845 | + } else if($new) { | ||
| 1846 | + $this->ktwebdavLog("201 Created", 'info', true); | ||
| 1847 | + return "201 Created"; | ||
| 1848 | + }else { | ||
| 1849 | + $this->ktwebdavLog("204 No Content", 'info', true); | ||
| 1850 | + return "204 No Content"; | ||
| 1851 | + } | ||
| 1852 | + } | ||
| 1853 | + | ||
| 1854 | + /* ** Get the destination folder object and the source document object. | ||
| 1855 | + Check if user has permission to write to the document and folder. | ||
| 1856 | + Move the document. ** */ | ||
| 1825 | $oDestFolder = Folder::get($iDestFolder); | 1857 | $oDestFolder = Folder::get($iDestFolder); |
| 1826 | $this->ktwebdavLog("Got a destination folder of " . print_r($oDestFolder, true), 'info', true); | 1858 | $this->ktwebdavLog("Got a destination folder of " . print_r($oDestFolder, true), 'info', true); |
| 1827 | 1859 | ||
| @@ -1832,57 +1864,20 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | @@ -1832,57 +1864,20 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | ||
| 1832 | return "403 Forbidden - User does not have sufficient permissions"; | 1864 | return "403 Forbidden - User does not have sufficient permissions"; |
| 1833 | } | 1865 | } |
| 1834 | 1866 | ||
| 1835 | - $oOriginalFolder = $oSrcFolder; | ||
| 1836 | - $iOriginalFolderPermissionObjectId = $oOriginalFolder->getPermissionObjectId(); | ||
| 1837 | - $iDocumentPermissionObjectId = $oDocument->getPermissionObjectId(); | 1867 | + $reason = (isset($_SERVER['HTTP_REASON']) && !empty($_SERVER['HTTP_REASON'])) ? $_SERVER['HTTP_REASON'] : "KTWebDAV Move."; |
| 1838 | 1868 | ||
| 1839 | - if ($iDocumentPermissionObjectId === $iOriginalFolderPermissionObjectId) { | ||
| 1840 | - $oDocument->setPermissionObjectId($oDestFolder->getPermissionObjectId()); | ||
| 1841 | - } | 1869 | + $res = KTDocumentUtil::move($oDocument, $oDestFolder, $oUser, $reason); |
| 1842 | 1870 | ||
| 1843 | - //put the document in the new folder | ||
| 1844 | - $oDocument->setFolderID($oDestFolder->getId()); | ||
| 1845 | - if (!$oDocument->update(true)) { | ||
| 1846 | - return "502 Bad Gateway - Document update failed."; | ||
| 1847 | - } | ||
| 1848 | - | ||
| 1849 | - //move the document on the file system | ||
| 1850 | - $oStorage =& KTStorageManagerUtil::getSingleton(); | ||
| 1851 | - if (!$oStorage->moveDocument($oDocument, $oSrcFolder, $oDestFolder)) { | ||
| 1852 | - $oDocument->setFolderID($oSrcDocumentFolder->getId()); | ||
| 1853 | - $oDocument->update(true); | ||
| 1854 | - return "502 Bad Gateway"; | ||
| 1855 | - } | ||
| 1856 | - | ||
| 1857 | - $sMoveMessage = sprintf("Moved from %s/%s to %s/%s: %s", | ||
| 1858 | - $oSrcFolder->getFullPath(), | ||
| 1859 | - $oSrcFolder->getName(), | ||
| 1860 | - $oDestFolder->getFullPath(), | ||
| 1861 | - $oDestFolder->getName(), | ||
| 1862 | - $_SERVER['HTTP_REASON']); | ||
| 1863 | - | ||
| 1864 | - // create the document transaction record | ||
| 1865 | - $oDocumentTransaction = & new DocumentTransaction($oDocument, $sMoveMessage, 'ktcore.transactions.move'); | ||
| 1866 | - $oDocumentTransaction->create(); | ||
| 1867 | - | ||
| 1868 | - $oKTTriggerRegistry = KTTriggerRegistry::getSingleton(); | ||
| 1869 | - $aTriggers = $oKTTriggerRegistry->getTriggers('moveDocument', 'postValidate'); | ||
| 1870 | - foreach ($aTriggers as $aTrigger) { | ||
| 1871 | - $sTrigger = $aTrigger[0]; | ||
| 1872 | - $oTrigger = new $sTrigger; | ||
| 1873 | - $aInfo = array( | ||
| 1874 | - "document" => $oDocument, | ||
| 1875 | - "old_folder" => $oSrcFolder, | ||
| 1876 | - "new_folder" => $oDestFolder, | ||
| 1877 | - ); | ||
| 1878 | - $oTrigger->setInfo($aInfo); | ||
| 1879 | - $ret = $oTrigger->postValidate(); | ||
| 1880 | - // FIXME: handle trigger subfailures. | 1871 | + if(PEAR::isError($res)){ |
| 1872 | + $this->ktwebdavLog("Move on document failed: ".$res->getMessage(), 'info', true); | ||
| 1873 | + return "500 Internal Server Error - Move on document failed."; | ||
| 1881 | } | 1874 | } |
| 1882 | 1875 | ||
| 1883 | if ($new) { | 1876 | if ($new) { |
| 1877 | + $this->ktwebdavLog("201 Created", 'info', true); | ||
| 1884 | return "201 Created"; | 1878 | return "201 Created"; |
| 1885 | } else { | 1879 | } else { |
| 1880 | + $this->ktwebdavLog("204 No Content", 'info', true); | ||
| 1886 | return "204 No Content"; | 1881 | return "204 No Content"; |
| 1887 | } | 1882 | } |
| 1888 | } | 1883 | } |
| @@ -1897,11 +1892,13 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | @@ -1897,11 +1892,13 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | ||
| 1897 | */ | 1892 | */ |
| 1898 | function _MOVEFolder($options, $iFolderID) { | 1893 | function _MOVEFolder($options, $iFolderID) { |
| 1899 | 1894 | ||
| 1895 | + /* ** Ensure that the destination path exists ** */ | ||
| 1900 | if ($options['dest'] == '') $options["dest"] = substr($options["dest_url"], strlen($_SERVER["SCRIPT_NAME"])); | 1896 | if ($options['dest'] == '') $options["dest"] = substr($options["dest_url"], strlen($_SERVER["SCRIPT_NAME"])); |
| 1901 | $this->ktwebdavLog("Entering _MOVEFolder. options are " . print_r($options, true), 'info', true); | 1897 | $this->ktwebdavLog("Entering _MOVEFolder. options are " . print_r($options, true), 'info', true); |
| 1902 | 1898 | ||
| 1899 | + /* ** RFC 2518 Section 8.9.2. A folder move must have a depth of 'infinity'. | ||
| 1900 | + Check the requested depth. If depth is set to '0' or '1' return a 400 error. ** */ | ||
| 1903 | if ($options["depth"] != "infinity") { | 1901 | if ($options["depth"] != "infinity") { |
| 1904 | - // RFC 2518 Section 9.2, last paragraph | ||
| 1905 | $this->ktwebdavLog("400 Bad request", 'info', true); | 1902 | $this->ktwebdavLog("400 Bad request", 'info', true); |
| 1906 | return "400 Bad request - depth must be 'inifinity'."; | 1903 | return "400 Bad request - depth must be 'inifinity'."; |
| 1907 | } | 1904 | } |
| @@ -1920,23 +1917,75 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | @@ -1920,23 +1917,75 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | ||
| 1920 | 1917 | ||
| 1921 | global $default; | 1918 | global $default; |
| 1922 | 1919 | ||
| 1920 | + /* ** Get the relevant paths. | ||
| 1921 | + Check whether the destination path refers to a folder / document. ** */ | ||
| 1923 | $source_path = $options["path"]; | 1922 | $source_path = $options["path"]; |
| 1924 | $dest_path = urldecode($options["dest"]); | 1923 | $dest_path = urldecode($options["dest"]); |
| 1924 | + list($iDestFolder, $iDestDoc) = $this->_folderOrDocument($dest_path); | ||
| 1925 | 1925 | ||
| 1926 | + /* ** Get the source folder objects. | ||
| 1927 | + If the destination document is null, then the destination is an existing folder. Check overwrite. | ||
| 1928 | + If overwrite is true, then check permissions and delete the folder, continue. | ||
| 1929 | + If the destination document returns an id, then the destination is a document, check overwrite. | ||
| 1930 | + If overwrite is true, then check permissions and delete the document, continue. | ||
| 1931 | + If the destination document is false, then continue. ** */ | ||
| 1926 | $oSrcFolder = Folder::get($iFolderID); | 1932 | $oSrcFolder = Folder::get($iFolderID); |
| 1933 | + $oDestFolder = Folder::get($iDestFolder); | ||
| 1927 | 1934 | ||
| 1928 | - list($iDestFolder, $iDestDoc) = $this->_folderOrDocument($dest_path); | 1935 | + $new = true; |
| 1936 | + if (is_null($iDestDoc)) { | ||
| 1937 | + // Folder exists | ||
| 1938 | + $this->ktwebdavLog("Destination Folder exists.", 'info', true); | ||
| 1939 | + $oReplaceFolder = $oDestFolder; | ||
| 1940 | + if ($options['overwrite'] != 'T') { | ||
| 1941 | + $this->ktwebdavLog("Overwrite needs to be TRUE.", 'info', true); | ||
| 1942 | + return "412 Precondition Failed - Destination Folder exists. Overwrite needs to be TRUE."; | ||
| 1943 | + } | ||
| 1944 | + $this->ktwebdavLog("Overwrite is TRUE, deleting Destination Folder.", 'info', true); | ||
| 1929 | 1945 | ||
| 1930 | - $oDestFolder = Folder::get($iDestFolder); | 1946 | + // Check if the user has permissions to delete this folder |
| 1947 | + $oPerm =& KTPermission::getByName('ktcore.permissions.delete'); | ||
| 1948 | + $oUser =& User::get($this->userID); | ||
| 1931 | 1949 | ||
| 1932 | - // Is this a rename? | ||
| 1933 | - if (dirname($source_path) == dirname($dest_path)) { | ||
| 1934 | - // This is a rename | ||
| 1935 | - //if ($options['overwrite'] != 'T') { | ||
| 1936 | - // $this->ktwebdavLog("This is a Rename. Overwrite needs to be TRUE.", 'info', true); | ||
| 1937 | - // return "412 Precondition Failed - This is a Rename. Overwrite needs to be TRUE."; | ||
| 1938 | - //} | 1950 | + if (!KTPermissionUtil::userHasPermissionOnItem($oUser, $oPerm, $oReplaceFolder)) { |
| 1951 | + return "403 Forbidden - User does not have sufficient permissions"; | ||
| 1952 | + } | ||
| 1953 | + | ||
| 1954 | + KTFolderUtil::delete($oReplaceFolder, $oUser, 'KTWebDAV move overwrites target.'); | ||
| 1955 | + | ||
| 1956 | + // Destination folder has been replaced so we need to get the parent folder object | ||
| 1957 | + list($iDestFolder, $iDestDoc) = $this->_folderOrDocument($dest_path); | ||
| 1958 | + $oDestFolder = Folder::get($iDestFolder); | ||
| 1959 | + | ||
| 1960 | + $new = false; | ||
| 1961 | + } else if ($iDestDoc !== false) { | ||
| 1962 | + // Destination is a document | ||
| 1963 | + $this->ktwebdavLog("Destination is a document.", 'info', true); | ||
| 1964 | + $oReplaceDoc = Document::get($iDestDoc); | ||
| 1965 | + if ($options['overwrite'] != 'T') { | ||
| 1966 | + $this->ktwebdavLog("Overwrite needs to be TRUE.", 'info', true); | ||
| 1967 | + return "412 Precondition Failed - Destination Folder is a document. Overwrite needs to be TRUE."; | ||
| 1968 | + } | ||
| 1969 | + $this->ktwebdavLog("Overwrite is TRUE, deleting Destination Document.", 'info', true); | ||
| 1970 | + | ||
| 1971 | + // Check if the user has permissions to delete this document | ||
| 1972 | + $oPerm =& KTPermission::getByName('ktcore.permissions.delete'); | ||
| 1973 | + $oUser =& User::get($this->userID); | ||
| 1974 | + | ||
| 1975 | + if (!KTPermissionUtil::userHasPermissionOnItem($oUser, $oPerm, $oReplaceDoc)) { | ||
| 1976 | + return "403 Forbidden - User does not have sufficient permissions"; | ||
| 1977 | + } | ||
| 1978 | + KTDocumentUtil::delete($oReplaceDoc, 'KTWebDAV move overwrites target.'); | ||
| 1979 | + $new = false; | ||
| 1980 | + } | ||
| 1939 | 1981 | ||
| 1982 | + /* ** Check if the source and destination directories are the same and the destination is not an existing folder. | ||
| 1983 | + Then action is probably a rename. | ||
| 1984 | + Check if user has permission to write to the folder. | ||
| 1985 | + Rename the document. ** */ | ||
| 1986 | + if (dirname($source_path) == dirname($dest_path) && !is_null($iDestDoc)) { | ||
| 1987 | + // This is a rename | ||
| 1988 | + $this->ktwebdavLog("Rename collection.", 'info', true); | ||
| 1940 | $this->ktwebdavLog("Got an oSrcFolder of " . print_r($oSrcFolder, true), 'info', true); | 1989 | $this->ktwebdavLog("Got an oSrcFolder of " . print_r($oSrcFolder, true), 'info', true); |
| 1941 | $this->ktwebdavLog("Got an new name of " . basename($dest_path), 'info', true); | 1990 | $this->ktwebdavLog("Got an new name of " . basename($dest_path), 'info', true); |
| 1942 | 1991 | ||
| @@ -1952,36 +2001,22 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | @@ -1952,36 +2001,22 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | ||
| 1952 | if (PEAR::isError($res) || is_null($res) || ($res === false)) { | 2001 | if (PEAR::isError($res) || is_null($res) || ($res === false)) { |
| 1953 | return "404 Not Found - " . $res->getMessage(); | 2002 | return "404 Not Found - " . $res->getMessage(); |
| 1954 | } else { | 2003 | } else { |
| 1955 | - $this->ktwebdavLog("201 Created", 'info', true); | ||
| 1956 | - return "201 Created"; | ||
| 1957 | - } | ||
| 1958 | - | ||
| 1959 | - } | ||
| 1960 | - | ||
| 1961 | - if (is_null($iDestDoc)) { | ||
| 1962 | - // the dest is a folder | ||
| 1963 | - } else if ($iDestDoc !== false) { | ||
| 1964 | - // Folder exists | ||
| 1965 | - $this->ktwebdavLog("Destination Folder exists.", 'info', true); | ||
| 1966 | - $oReplaceFolder = Folder::get($iDestDoc); | ||
| 1967 | - if ($options['overwrite'] != 'T') { | ||
| 1968 | - $this->ktwebdavLog("Overwrite needs to be TRUE.", 'info', true); | ||
| 1969 | - return "412 Precondition Failed - Destination Folder exists. Overwrite needs to be TRUE."; | 2004 | + if($new){ |
| 2005 | + $this->ktwebdavLog("201 Created", 'info', true); | ||
| 2006 | + return "201 Created"; | ||
| 2007 | + }else{ | ||
| 2008 | + $this->ktwebdavLog("204 No Content", 'info', true); | ||
| 2009 | + return "204 No Content"; | ||
| 2010 | + } | ||
| 1970 | } | 2011 | } |
| 1971 | - $this->ktwebdavLog("Overwrite is TRUE, deleting Destination Folder.", 'info', true); | ||
| 1972 | 2012 | ||
| 1973 | - // Check if the user has permissions to delete this folder | ||
| 1974 | - $oPerm =& KTPermission::getByName('ktcore.permissions.delete'); | ||
| 1975 | - $oUser =& User::get($this->userID); | ||
| 1976 | - if (!KTPermissionUtil::userHasPermissionOnItem($oUser, $oPerm, $oReplaceFolder)) { | ||
| 1977 | - return "403 Forbidden - User does not have sufficient permissions"; | ||
| 1978 | - } | ||
| 1979 | - KTFolderUtil::delete($oReplaceFolder, 'KTWebDAV move overwrites target.'); | ||
| 1980 | - $new = false; | ||
| 1981 | } | 2013 | } |
| 1982 | 2014 | ||
| 1983 | include_once(KT_LIB_DIR . '/foldermanagement/folderutil.inc.php'); | 2015 | include_once(KT_LIB_DIR . '/foldermanagement/folderutil.inc.php'); |
| 1984 | 2016 | ||
| 2017 | + /* ** Get the destination folder object and the source document object. | ||
| 2018 | + Check if user has permission to write to the folder. | ||
| 2019 | + Move the folder. ** */ | ||
| 1985 | $oUser =& User::get($this->userID); | 2020 | $oUser =& User::get($this->userID); |
| 1986 | $this->ktwebdavLog("Got an oSrcFolder of " . print_r($oSrcFolder, true), 'info', true); | 2021 | $this->ktwebdavLog("Got an oSrcFolder of " . print_r($oSrcFolder, true), 'info', true); |
| 1987 | $this->ktwebdavLog("Got an oDestFolder of " . print_r($oDestFolder, true), 'info', true); | 2022 | $this->ktwebdavLog("Got an oDestFolder of " . print_r($oDestFolder, true), 'info', true); |
| @@ -1993,18 +2028,29 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | @@ -1993,18 +2028,29 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | ||
| 1993 | if (!KTPermissionUtil::userHasPermissionOnItem($oUser, $oPerm, $oDestFolder)) { | 2028 | if (!KTPermissionUtil::userHasPermissionOnItem($oUser, $oPerm, $oDestFolder)) { |
| 1994 | return "403 Forbidden - User does not have sufficient permissions"; | 2029 | return "403 Forbidden - User does not have sufficient permissions"; |
| 1995 | } | 2030 | } |
| 1996 | - KTFolderUtil::move($oSrcFolder, $oDestFolder, $oUser); | ||
| 1997 | 2031 | ||
| 1998 | - $this->ktwebdavLog("201 Created", 'info', true); | ||
| 1999 | - return "201 Created"; | 2032 | + $res = KTFolderUtil::move($oSrcFolder, $oDestFolder, $oUser); |
| 2033 | + | ||
| 2034 | + if(PEAR::isError($res)){ | ||
| 2035 | + $this->ktwebdavLog("Move on folder failed: ".$res->getMessage(), 'info', true); | ||
| 2036 | + return "500 Internal Server Error - Move on folder failed."; | ||
| 2037 | + } | ||
| 2000 | 2038 | ||
| 2039 | + if($new){ | ||
| 2040 | + $this->ktwebdavLog("201 Created", 'info', true); | ||
| 2041 | + return "201 Created"; | ||
| 2042 | + }else{ | ||
| 2043 | + $this->ktwebdavLog("204 No Content", 'info', true); | ||
| 2044 | + return "204 No Content"; | ||
| 2045 | + } | ||
| 2001 | } | 2046 | } |
| 2002 | 2047 | ||
| 2003 | /** | 2048 | /** |
| 2004 | * COPY method handler | 2049 | * COPY method handler |
| 2050 | + * Method checks if the source path refers to a document / folder then calls the appropriate method handler. | ||
| 2005 | * | 2051 | * |
| 2006 | - * @param array parameter passing array | ||
| 2007 | - * @param string delete source flag | 2052 | + * @param $options array parameter passing array |
| 2053 | + * @param $del string delete source flag | ||
| 2008 | * @return string HTTP status code or false | 2054 | * @return string HTTP status code or false |
| 2009 | */ | 2055 | */ |
| 2010 | function COPY($options, $del = false) | 2056 | function COPY($options, $del = false) |
| @@ -2012,6 +2058,7 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | @@ -2012,6 +2058,7 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | ||
| 2012 | $this->ktwebdavLog("Entering COPY. options are " . print_r($options, true), 'info', true); | 2058 | $this->ktwebdavLog("Entering COPY. options are " . print_r($options, true), 'info', true); |
| 2013 | $this->ktwebdavLog("del is: " . $del, 'info', true); | 2059 | $this->ktwebdavLog("del is: " . $del, 'info', true); |
| 2014 | 2060 | ||
| 2061 | + /* ** Check that writing to the server is allowed * **/ | ||
| 2015 | if ($this->checkSafeMode()) { | 2062 | if ($this->checkSafeMode()) { |
| 2016 | 2063 | ||
| 2017 | if (!empty($_SERVER["CONTENT_LENGTH"])) { // no body parsing yet | 2064 | if (!empty($_SERVER["CONTENT_LENGTH"])) { // no body parsing yet |
| @@ -2025,6 +2072,10 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | @@ -2025,6 +2072,10 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | ||
| 2025 | return "502 bad gateway - No copying to different WebDAV Servers yet"; | 2072 | return "502 bad gateway - No copying to different WebDAV Servers yet"; |
| 2026 | } | 2073 | } |
| 2027 | */ | 2074 | */ |
| 2075 | + | ||
| 2076 | + /* ** Get the path to the document/folder to be copied. | ||
| 2077 | + Call function to check if the path refers to a document or a folder. | ||
| 2078 | + Return 404 error if the path is invalid. ** */ | ||
| 2028 | $source_path = $options["path"]; | 2079 | $source_path = $options["path"]; |
| 2029 | $this->ktwebdavLog("SourcePath is: " . $source_path, 'info', true); | 2080 | $this->ktwebdavLog("SourcePath is: " . $source_path, 'info', true); |
| 2030 | $source_res = $this->_folderOrDocument($source_path); | 2081 | $source_res = $this->_folderOrDocument($source_path); |
| @@ -2033,13 +2084,19 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | @@ -2033,13 +2084,19 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | ||
| 2033 | return "404 Not found - The document could not be found."; | 2084 | return "404 Not found - The document could not be found."; |
| 2034 | } | 2085 | } |
| 2035 | 2086 | ||
| 2087 | + /* ** Get the returned parent folder id and document/folder id. | ||
| 2088 | + If the parent folder id is false, return 404 error. | ||
| 2089 | + If the document id is either false or null, then the source is a folder. | ||
| 2090 | + If the document id exists then the source is a document. | ||
| 2091 | + If the source is a folder then call _COPYFolder. | ||
| 2092 | + If the source is a document then check if its checked out and call _COPYDocument. ** */ | ||
| 2036 | list($iFolderID, $iDocumentID) = $source_res; | 2093 | list($iFolderID, $iDocumentID) = $source_res; |
| 2037 | - if ($iDocumentID === false) { | 2094 | + if ($iFolderID === false && ($iDocumentID === false || is_null($iDocumentID))) { |
| 2038 | $this->ktwebdavLog("404 Not found - The folder could not be found.", 'info', true); | 2095 | $this->ktwebdavLog("404 Not found - The folder could not be found.", 'info', true); |
| 2039 | return "404 Not found - The folder could not be found."; | 2096 | return "404 Not found - The folder could not be found."; |
| 2040 | } | 2097 | } |
| 2041 | 2098 | ||
| 2042 | - if (is_null($iDocumentID)) { | 2099 | + if (is_null($iDocumentID) || $iDocumentID === false) { |
| 2043 | // Source is a folder | 2100 | // Source is a folder |
| 2044 | $this->ktwebdavLog("Source is a Folder.", 'info', true); | 2101 | $this->ktwebdavLog("Source is a Folder.", 'info', true); |
| 2045 | $copystat = $this->_COPYFolder($options, $iFolderID); | 2102 | $copystat = $this->_COPYFolder($options, $iFolderID); |
| @@ -2049,13 +2106,15 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | @@ -2049,13 +2106,15 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | ||
| 2049 | $this->ktwebdavLog("Source is a Document.", 'info', true); | 2106 | $this->ktwebdavLog("Source is a Document.", 'info', true); |
| 2050 | 2107 | ||
| 2051 | if ($this->canCopyMoveRenameDocument($iDocumentID)) { | 2108 | if ($this->canCopyMoveRenameDocument($iDocumentID)) { |
| 2052 | - $copystat = $this->_COPYDocument($options, $iFolderID, $iDocumentID, $dest_folder_id); | 2109 | + $copystat = $this->_COPYDocument($options, $iFolderID, $iDocumentID); |
| 2053 | } else { | 2110 | } else { |
| 2054 | - return "Cannot COPY document because it is checked out by another user."; | 2111 | + // Document is locked |
| 2112 | + return "423 Locked - Cannot COPY document because it is checked out by another user."; | ||
| 2055 | } | 2113 | } |
| 2056 | 2114 | ||
| 2057 | } | 2115 | } |
| 2058 | 2116 | ||
| 2117 | + /* ** Deprecated. If the request is a move then delete the source ** | ||
| 2059 | // Delete the source if this is a move and the copy was ok | 2118 | // Delete the source if this is a move and the copy was ok |
| 2060 | if ($del && ($copystat{0} == "2")) { | 2119 | if ($del && ($copystat{0} == "2")) { |
| 2061 | $delstat = $this->DELETE(array("path" => $options["path"])); | 2120 | $delstat = $this->DELETE(array("path" => $options["path"])); |
| @@ -2064,6 +2123,7 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | @@ -2064,6 +2123,7 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | ||
| 2064 | return $delstat; | 2123 | return $delstat; |
| 2065 | } | 2124 | } |
| 2066 | } | 2125 | } |
| 2126 | + */ | ||
| 2067 | 2127 | ||
| 2068 | $this->ktwebdavLog("Final copystat result is: " . $copystat, 'info', true); | 2128 | $this->ktwebdavLog("Final copystat result is: " . $copystat, 'info', true); |
| 2069 | return $copystat; | 2129 | return $copystat; |
| @@ -2074,16 +2134,30 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | @@ -2074,16 +2134,30 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | ||
| 2074 | /** | 2134 | /** |
| 2075 | * COPY method helper for Documents | 2135 | * COPY method helper for Documents |
| 2076 | * | 2136 | * |
| 2077 | - * @param array parameter passing array | ||
| 2078 | - * @param int Folder ID | ||
| 2079 | - * @param int Document ID | 2137 | + * @param $options array parameter passing array |
| 2138 | + * @param $iFolderID int Folder ID | ||
| 2139 | + * @param $iDocumentID int Document ID | ||
| 2080 | * @return string HTTP status code or false | 2140 | * @return string HTTP status code or false |
| 2081 | */ | 2141 | */ |
| 2082 | function _COPYDocument($options, $iFolderID, $iDocumentID) { | 2142 | function _COPYDocument($options, $iFolderID, $iDocumentID) { |
| 2083 | 2143 | ||
| 2144 | + /* ** Ensure that the destination path exists ** */ | ||
| 2084 | if ($options['dest'] == '') $options["dest"] = substr($options["dest_url"], strlen($_SERVER["SCRIPT_NAME"])); | 2145 | if ($options['dest'] == '') $options["dest"] = substr($options["dest_url"], strlen($_SERVER["SCRIPT_NAME"])); |
| 2085 | $this->ktwebdavLog("Entering _COPYDocument. options are " . print_r($options, true), 'info', true); | 2146 | $this->ktwebdavLog("Entering _COPYDocument. options are " . print_r($options, true), 'info', true); |
| 2086 | 2147 | ||
| 2148 | + /* ** Get the relevant paths. Get the basename of the destination path as the destination filename. | ||
| 2149 | + Check whether the destination path refers to a folder / document. ** */ | ||
| 2150 | + $source_path = $options["path"]; | ||
| 2151 | + $dest_path = urldecode($options["dest"]); | ||
| 2152 | + $sDestFileName = basename($dest_path); | ||
| 2153 | + | ||
| 2154 | + list($iDestFolder, $iDestDoc) = $this->_folderOrDocument($dest_path); | ||
| 2155 | + | ||
| 2156 | + if($iDestFolder === false){ | ||
| 2157 | + return "409 Conflict - Destination folder does not exist."; | ||
| 2158 | + } | ||
| 2159 | + | ||
| 2160 | + /* ** Depth must be infinity to copy a document ** */ | ||
| 2087 | if ($options["depth"] != "infinity") { | 2161 | if ($options["depth"] != "infinity") { |
| 2088 | // RFC 2518 Section 9.2, last paragraph | 2162 | // RFC 2518 Section 9.2, last paragraph |
| 2089 | $this->ktwebdavLog("400 Bad request", 'info', true); | 2163 | $this->ktwebdavLog("400 Bad request", 'info', true); |
| @@ -2092,17 +2166,20 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | @@ -2092,17 +2166,20 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | ||
| 2092 | 2166 | ||
| 2093 | global $default; | 2167 | global $default; |
| 2094 | 2168 | ||
| 2095 | - $source_path = $options["path"]; | ||
| 2096 | - $dest_path = urldecode($options["dest"]); | ||
| 2097 | - | 2169 | + /* ** Get the source folder object. |
| 2170 | + If the destination document is null, then the destination is a folder, set the destination filename to empty, continue. | ||
| 2171 | + If the destination document returns an id, then the document exists. Check overwrite. | ||
| 2172 | + If overwrite is true, then check permissions and delete the document, continue. | ||
| 2173 | + If the destination document is false, then continue. ** */ | ||
| 2098 | $oSrcFolder = Folder::get($iFolderID); | 2174 | $oSrcFolder = Folder::get($iFolderID); |
| 2099 | 2175 | ||
| 2100 | - list($iDestFolder, $iDestDoc) = $this->_folderOrDocument($dest_path); | ||
| 2101 | - | 2176 | + $new = true; |
| 2102 | if (is_null($iDestDoc)) { | 2177 | if (is_null($iDestDoc)) { |
| 2103 | // the dest is a folder | 2178 | // the dest is a folder |
| 2104 | // $this->ktwebdavLog("400 Bad request", 'info', true); | 2179 | // $this->ktwebdavLog("400 Bad request", 'info', true); |
| 2105 | - return "400 Bad request - Destination is a Folder"; | 2180 | + $this->ktwebdavLog("Destination is a folder.", 'info', true); |
| 2181 | + $sDestFileName = ''; | ||
| 2182 | + //return "400 Bad request - Destination is a Folder"; | ||
| 2106 | } else if ($iDestDoc !== false) { | 2183 | } else if ($iDestDoc !== false) { |
| 2107 | // Document exists | 2184 | // Document exists |
| 2108 | $this->ktwebdavLog("Destination Document exists.", 'info', true); | 2185 | $this->ktwebdavLog("Destination Document exists.", 'info', true); |
| @@ -2123,25 +2200,33 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | @@ -2123,25 +2200,33 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | ||
| 2123 | $new = false; | 2200 | $new = false; |
| 2124 | } | 2201 | } |
| 2125 | 2202 | ||
| 2203 | + /* ** Get the destination folder object and the source document object. | ||
| 2204 | + Check if user has permission to write to the document and folder. | ||
| 2205 | + Copy the document. ** */ | ||
| 2126 | $oDestFolder = Folder::get($iDestFolder); | 2206 | $oDestFolder = Folder::get($iDestFolder); |
| 2127 | $oSrcDoc = Document::get($iDocumentID); | 2207 | $oSrcDoc = Document::get($iDocumentID); |
| 2128 | 2208 | ||
| 2129 | include_once(KT_LIB_DIR . '/foldermanagement/folderutil.inc.php'); | 2209 | include_once(KT_LIB_DIR . '/foldermanagement/folderutil.inc.php'); |
| 2130 | 2210 | ||
| 2131 | - $this->ktwebdavLog("Got an oSrcDoc of " . print_r($oSrcDoc, true), 'info', true); | ||
| 2132 | - $this->ktwebdavLog("Got an oDestFolder of " . print_r($oDestFolder, true), 'info', true); | 2211 | + $this->ktwebdavLog("Got an oSrcDoc of " .$oSrcDoc->getName() . print_r($oSrcDoc, true), 'info', true); |
| 2212 | + $this->ktwebdavLog("Got an oDestFolder of " .$oDestFolder->getName() . print_r($oDestFolder, true), 'info', true); | ||
| 2133 | 2213 | ||
| 2134 | // Check if the user has permissions to write in this folder | 2214 | // Check if the user has permissions to write in this folder |
| 2135 | $oPerm =& KTPermission::getByName('ktcore.permissions.write'); | 2215 | $oPerm =& KTPermission::getByName('ktcore.permissions.write'); |
| 2136 | $oUser =& User::get($this->userID); | 2216 | $oUser =& User::get($this->userID); |
| 2137 | - if (!KTPermissionUtil::userHasPermissionOnItem($oUser, $oPerm, $oSrcDoc)) { | 2217 | + if (!KTPermissionUtil::userHasPermissionOnItem($oUser, $oPerm, $oDestFolder)) { |
| 2138 | return "403 Forbidden - User does not have sufficient permissions"; | 2218 | return "403 Forbidden - User does not have sufficient permissions"; |
| 2139 | } | 2219 | } |
| 2140 | - KTDocumentUtil::copy($oSrcDoc, $oDestFolder, $_SERVER['HTTP_REASON']); | ||
| 2141 | 2220 | ||
| 2142 | - // FIXME: Do failure checking here | 2221 | + $reason = (isset($_SERVER['HTTP_REASON']) && !empty($_SERVER['HTTP_REASON'])) ? $_SERVER['HTTP_REASON'] : "KTWebDAV Copy."; |
| 2222 | + | ||
| 2223 | + $oDesDoc = KTDocumentUtil::copy($oSrcDoc, $oDestFolder, $reason, $sDestFileName); | ||
| 2224 | + | ||
| 2225 | + if(PEAR::isError($oDesDoc)){ | ||
| 2226 | + $this->ktwebdavLog("Copy on document failed: ".$oDesDoc->getMessage(), 'info', true); | ||
| 2227 | + return "500 Internal Server Error - Copy on document failed."; | ||
| 2228 | + } | ||
| 2143 | 2229 | ||
| 2144 | - $new = false; | ||
| 2145 | if ($new) { | 2230 | if ($new) { |
| 2146 | $this->ktwebdavLog("201 Created", 'info', true); | 2231 | $this->ktwebdavLog("201 Created", 'info', true); |
| 2147 | return "201 Created"; | 2232 | return "201 Created"; |
| @@ -2160,37 +2245,52 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | @@ -2160,37 +2245,52 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | ||
| 2160 | */ | 2245 | */ |
| 2161 | function _COPYFolder($options, $iFolderID) { | 2246 | function _COPYFolder($options, $iFolderID) { |
| 2162 | 2247 | ||
| 2248 | + /* ** Ensure that the destination path exists ** */ | ||
| 2163 | if ($options['dest'] == '') $options["dest"] = substr($options["dest_url"], strlen($_SERVER["SCRIPT_NAME"])); | 2249 | if ($options['dest'] == '') $options["dest"] = substr($options["dest_url"], strlen($_SERVER["SCRIPT_NAME"])); |
| 2164 | $this->ktwebdavLog("Entering _COPYFolder. options are " . print_r($options, true), 'info', true); | 2250 | $this->ktwebdavLog("Entering _COPYFolder. options are " . print_r($options, true), 'info', true); |
| 2165 | 2251 | ||
| 2252 | + /* ** RFC 2518 Section 8.8.3. DAV compliant servers must support depth headers of '0' and 'infinity'. | ||
| 2253 | + Check the requested depth. If depth is set to '0', set copyall to false. A depth of 0 indicates | ||
| 2254 | + that the folder is copied without any children. If depth is set to '1', return a 400 error. ** */ | ||
| 2255 | + $copyAll = true; | ||
| 2166 | if ($options["depth"] != "infinity") { | 2256 | if ($options["depth"] != "infinity") { |
| 2167 | - // RFC 2518 Section 9.2, last paragraph | ||
| 2168 | - $this->ktwebdavLog("400 Bad request", 'info', true); | ||
| 2169 | - return "400 Bad request - Depth must be 'infinity'."; | 2257 | + if($options['depth'] == '0'){ |
| 2258 | + $copyAll = false; | ||
| 2259 | + $this->ktwebdavLog("Depth is 0. Copy only the base folder.", 'info', true); | ||
| 2260 | + }else{ | ||
| 2261 | + $this->ktwebdavLog("400 Bad request. Depth must be infinity or 0.", 'info', true); | ||
| 2262 | + return "400 Bad request - Depth must be 'infinity' or '0'."; | ||
| 2263 | + } | ||
| 2170 | } | 2264 | } |
| 2171 | 2265 | ||
| 2172 | global $default; | 2266 | global $default; |
| 2173 | 2267 | ||
| 2174 | $new = true; | 2268 | $new = true; |
| 2175 | 2269 | ||
| 2270 | + /* ** Get the relevant paths. Get the basename of the destination path as the destination path name. | ||
| 2271 | + Check whether the destination path refers to a folder / document. ** */ | ||
| 2176 | $source_path = $options["path"]; | 2272 | $source_path = $options["path"]; |
| 2177 | $dest_path = urldecode($options["dest"]); | 2273 | $dest_path = urldecode($options["dest"]); |
| 2178 | - | ||
| 2179 | - $oSrcFolder = Folder::get($iFolderID); | 2274 | + $sDestPathName = basename($dest_path); |
| 2180 | 2275 | ||
| 2181 | list($iDestFolder, $iDestDoc) = $this->_folderOrDocument($dest_path); | 2276 | list($iDestFolder, $iDestDoc) = $this->_folderOrDocument($dest_path); |
| 2182 | 2277 | ||
| 2278 | + /* ** Get the source and destination folder objects. | ||
| 2279 | + If the destination document is null, then the destination is an existing folder. Check overwrite. | ||
| 2280 | + If overwrite is true, then check permissions and delete the folder, continue. | ||
| 2281 | + If the destination document returns an id, then the destination is a document, return 409 error. | ||
| 2282 | + If the destination document is false, then continue. ** */ | ||
| 2283 | + $oSrcFolder = Folder::get($iFolderID); | ||
| 2183 | $oDestFolder = Folder::get($iDestFolder); | 2284 | $oDestFolder = Folder::get($iDestFolder); |
| 2184 | 2285 | ||
| 2185 | include_once(KT_LIB_DIR . '/foldermanagement/folderutil.inc.php'); | 2286 | include_once(KT_LIB_DIR . '/foldermanagement/folderutil.inc.php'); |
| 2186 | 2287 | ||
| 2187 | - if (is_null($iDestDoc)) { | ||
| 2188 | - // the dest is a folder | ||
| 2189 | - $this->ktwebdavLog("The Destination is a Folder.", 'info', true); | ||
| 2190 | - } else if ($iDestDoc !== false) { | ||
| 2191 | - // Folder exists | 2288 | + if(is_null($iDestDoc)) { |
| 2289 | + // Destination is a folder and exists | ||
| 2290 | + //$sDestPathName = ''; | ||
| 2192 | $this->ktwebdavLog("Destination Folder exists.", 'info', true); | 2291 | $this->ktwebdavLog("Destination Folder exists.", 'info', true); |
| 2193 | - $oReplaceFolder = Folder::get($iDestDoc); | 2292 | + |
| 2293 | + $oReplaceFolder = $oDestFolder; | ||
| 2194 | if ($options['overwrite'] != 'T') { | 2294 | if ($options['overwrite'] != 'T') { |
| 2195 | $this->ktwebdavLog("Overwrite needs to be TRUE.", 'info', true); | 2295 | $this->ktwebdavLog("Overwrite needs to be TRUE.", 'info', true); |
| 2196 | return "412 Precondition Failed - Destination Folder exists. Overwrite needs to be TRUE."; | 2296 | return "412 Precondition Failed - Destination Folder exists. Overwrite needs to be TRUE."; |
| @@ -2203,10 +2303,21 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | @@ -2203,10 +2303,21 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | ||
| 2203 | if (!KTPermissionUtil::userHasPermissionOnItem($oUser, $oPerm, $oReplaceFolder)) { | 2303 | if (!KTPermissionUtil::userHasPermissionOnItem($oUser, $oPerm, $oReplaceFolder)) { |
| 2204 | return "403 Forbidden - User does not have sufficient permissions"; | 2304 | return "403 Forbidden - User does not have sufficient permissions"; |
| 2205 | } | 2305 | } |
| 2206 | - KTFolderUtil::delete($oReplaceFolder, 'KTWebDAV move overwrites target.'); | 2306 | + KTFolderUtil::delete($oReplaceFolder, $oUser, 'KTWebDAV move overwrites target.'); |
| 2307 | + | ||
| 2308 | + // Destination folder has been deleted - get new object of destination parent folder | ||
| 2309 | + list($iDestFolder, $iDestDoc) = $this->_folderOrDocument($dest_path); | ||
| 2310 | + $oDestFolder = Folder::get($iDestFolder); | ||
| 2311 | + | ||
| 2207 | $new = false; | 2312 | $new = false; |
| 2313 | + } else if ($iDestDoc !== false) { | ||
| 2314 | + // Destination is a document | ||
| 2315 | + return "409 Conflict - Can't write a collection to a document"; | ||
| 2208 | } | 2316 | } |
| 2209 | 2317 | ||
| 2318 | + /* ** Get the destination folder object and the source document object. | ||
| 2319 | + Check if user has permission to write to the folder. | ||
| 2320 | + Copy the document. Pass parameters for the destination folder name and the depth of copy. ** */ | ||
| 2210 | $oUser =& User::get($this->userID); | 2321 | $oUser =& User::get($this->userID); |
| 2211 | $this->ktwebdavLog("Got an oSrcFolder of " . print_r($oSrcFolder, true), 'info', true); | 2322 | $this->ktwebdavLog("Got an oSrcFolder of " . print_r($oSrcFolder, true), 'info', true); |
| 2212 | $this->ktwebdavLog("Got an oDestFolder of " . print_r($oDestFolder, true), 'info', true); | 2323 | $this->ktwebdavLog("Got an oDestFolder of " . print_r($oDestFolder, true), 'info', true); |
| @@ -2218,7 +2329,15 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | @@ -2218,7 +2329,15 @@ class KTWebDAVServer extends HTTP_WebDAV_Server | ||
| 2218 | if (!KTPermissionUtil::userHasPermissionOnItem($oUser, $oPerm, $oDestFolder)) { | 2329 | if (!KTPermissionUtil::userHasPermissionOnItem($oUser, $oPerm, $oDestFolder)) { |
| 2219 | return "403 Forbidden - User does not have sufficient permissions"; | 2330 | return "403 Forbidden - User does not have sufficient permissions"; |
| 2220 | } | 2331 | } |
| 2221 | - KTFolderUtil::copy($oSrcFolder, $oDestFolder, $oUser, 'KTWebDAV Copy.'); | 2332 | + |
| 2333 | + $reason = (isset($_SERVER['HTTP_REASON']) && !empty($_SERVER['HTTP_REASON'])) ? $_SERVER['HTTP_REASON'] : "KTWebDAV Copy."; | ||
| 2334 | + | ||
| 2335 | + $res = KTFolderUtil::copy($oSrcFolder, $oDestFolder, $oUser, $reason, $sDestPathName, $copyAll); | ||
| 2336 | + | ||
| 2337 | + if(PEAR::isError($res)){ | ||
| 2338 | + $this->ktwebdavLog("Copy on folder failed: ".$res->getMessage(), 'info', true); | ||
| 2339 | + return "500 Internal Server Error - Copy on folder failed."; | ||
| 2340 | + } | ||
| 2222 | 2341 | ||
| 2223 | if ($new) { | 2342 | if ($new) { |
| 2224 | $this->ktwebdavLog("201 Created", 'info', true); | 2343 | $this->ktwebdavLog("201 Created", 'info', true); |
ktwebservice/nunit/authentication.cs
| @@ -14,7 +14,7 @@ namespace MonoTests.KnowledgeTree | @@ -14,7 +14,7 @@ namespace MonoTests.KnowledgeTree | ||
| 14 | [SetUp] | 14 | [SetUp] |
| 15 | public void SetUp() | 15 | public void SetUp() |
| 16 | { | 16 | { |
| 17 | - this._kt = new KnowledgeTreeService(); | 17 | + this._kt = new KTWebService(); |
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | [TearDown] | 20 | [TearDown] |
ktwebservice/nunit/document_add.cs
| @@ -5,55 +5,34 @@ using System.IO; | @@ -5,55 +5,34 @@ using System.IO; | ||
| 5 | namespace MonoTests.KnowledgeTree | 5 | namespace MonoTests.KnowledgeTree |
| 6 | { | 6 | { |
| 7 | [TestFixture] | 7 | [TestFixture] |
| 8 | - public class AddDocumentTest | 8 | + public class AddDocumentTest : KTTest |
| 9 | { | 9 | { |
| 10 | 10 | ||
| 11 | - private String _session; | ||
| 12 | - private KnowledgeTreeService _kt; | 11 | + |
| 13 | private int _docId; | 12 | private int _docId; |
| 14 | private int _folderId; | 13 | private int _folderId; |
| 15 | private String _filename; | 14 | private String _filename; |
| 16 | - private String _content; | ||
| 17 | - private bool _verbose; | ||
| 18 | - | ||
| 19 | - public AddDocumentTest() | ||
| 20 | - { | ||
| 21 | - | ||
| 22 | - this._verbose = true; | 15 | + private String _content; |
| 23 | 16 | ||
| 17 | + public AddDocumentTest() : base() | ||
| 18 | + { | ||
| 24 | this._folderId = 1; | 19 | this._folderId = 1; |
| 25 | - } | ||
| 26 | - | 20 | + } |
| 27 | 21 | ||
| 28 | [SetUp] | 22 | [SetUp] |
| 29 | public void SetUp() | 23 | public void SetUp() |
| 30 | - { | ||
| 31 | - this._kt = new KnowledgeTreeService(); | ||
| 32 | - //this._kt.Url = "http://ktdms.trunk/ktwebservice/webservice.php"; | ||
| 33 | - kt_response response = this._kt.login("admin","admin","127.0.0.1"); | ||
| 34 | - this._session = response.message; | ||
| 35 | - | 24 | + { |
| 36 | this._filename = Helper.isUnix()?"/tmp/kt_unit_test1.txt":"c:\\kt_unit_test1.txt"; | 25 | this._filename = Helper.isUnix()?"/tmp/kt_unit_test1.txt":"c:\\kt_unit_test1.txt"; |
| 37 | this._content = "hello world!"; | 26 | this._content = "hello world!"; |
| 38 | 27 | ||
| 39 | - Helper.writeFile(this._filename, this._content); | ||
| 40 | - | ||
| 41 | - | ||
| 42 | - } | 28 | + Helper.writeFile(this._filename, this._content); } |
| 43 | 29 | ||
| 44 | [TearDown] | 30 | [TearDown] |
| 45 | public void TearDown() | 31 | public void TearDown() |
| 46 | - { | ||
| 47 | - | ||
| 48 | - Helper.deleteFile(this._filename); | ||
| 49 | - | ||
| 50 | - | ||
| 51 | - this._kt.logout(this._session); | ||
| 52 | - } | ||
| 53 | - | ||
| 54 | - | ||
| 55 | - | ||
| 56 | - | 32 | + { |
| 33 | + Helper.deleteFile(this._filename); | ||
| 34 | + } | ||
| 35 | + | ||
| 57 | [Test] | 36 | [Test] |
| 58 | public void FindDocumentBeforeAdd() | 37 | public void FindDocumentBeforeAdd() |
| 59 | { | 38 | { |
| @@ -70,8 +49,7 @@ namespace MonoTests.KnowledgeTree | @@ -70,8 +49,7 @@ namespace MonoTests.KnowledgeTree | ||
| 70 | { | 49 | { |
| 71 | System.Console.WriteLine("document not found. that is ok!"); | 50 | System.Console.WriteLine("document not found. that is ok!"); |
| 72 | } | 51 | } |
| 73 | - } | ||
| 74 | - | 52 | + } |
| 75 | 53 | ||
| 76 | [Test] | 54 | [Test] |
| 77 | public void FindFolderBeforeAdd() | 55 | public void FindFolderBeforeAdd() |
| @@ -89,8 +67,7 @@ namespace MonoTests.KnowledgeTree | @@ -89,8 +67,7 @@ namespace MonoTests.KnowledgeTree | ||
| 89 | { | 67 | { |
| 90 | if (this._verbose) System.Console.WriteLine("folder not found. that is ok!"); | 68 | if (this._verbose) System.Console.WriteLine("folder not found. that is ok!"); |
| 91 | } | 69 | } |
| 92 | - } | ||
| 93 | - | 70 | + } |
| 94 | 71 | ||
| 95 | [Test] | 72 | [Test] |
| 96 | public void AddDocument() | 73 | public void AddDocument() |
| @@ -121,9 +98,9 @@ namespace MonoTests.KnowledgeTree | @@ -121,9 +98,9 @@ namespace MonoTests.KnowledgeTree | ||
| 121 | Assert.AreEqual("Administrator", response1.created_by); | 98 | Assert.AreEqual("Administrator", response1.created_by); |
| 122 | 99 | ||
| 123 | //Assert.IsTrue(response1.updated_date == null); | 100 | //Assert.IsTrue(response1.updated_date == null); |
| 124 | - Assert.IsTrue("" != response1.updated_date); | 101 | + Assert.IsTrue("" != response1.modified_date); |
| 125 | 102 | ||
| 126 | - Assert.AreEqual("Administrator", response1.updated_by); | 103 | + Assert.AreEqual("Administrator", response1.modified_by); |
| 127 | 104 | ||
| 128 | Assert.IsTrue(response1.document_id > 0); | 105 | Assert.IsTrue(response1.document_id > 0); |
| 129 | 106 | ||
| @@ -185,7 +162,7 @@ namespace MonoTests.KnowledgeTree | @@ -185,7 +162,7 @@ namespace MonoTests.KnowledgeTree | ||
| 185 | String filename = "kt unit test31"; | 162 | String filename = "kt unit test31"; |
| 186 | 163 | ||
| 187 | if (this._verbose) System.Console.WriteLine("Adding document : " + filename); | 164 | if (this._verbose) System.Console.WriteLine("Adding document : " + filename); |
| 188 | - FileUploader uploader = new FileUploader("http://ktdms.trunk/ktwebservice/upload.php"); | 165 | + FileUploader uploader = new FileUploader(); |
| 189 | 166 | ||
| 190 | uploader.upload(this._session, this._filename); | 167 | uploader.upload(this._session, this._filename); |
| 191 | String tempname = uploader.getFilename(); | 168 | String tempname = uploader.getFilename(); |
| @@ -203,10 +180,10 @@ namespace MonoTests.KnowledgeTree | @@ -203,10 +180,10 @@ namespace MonoTests.KnowledgeTree | ||
| 203 | 180 | ||
| 204 | Assert.AreEqual("Administrator", response1.created_by); | 181 | Assert.AreEqual("Administrator", response1.created_by); |
| 205 | 182 | ||
| 206 | - //Assert.IsTrue(response1.updated_date == null); | ||
| 207 | - Assert.IsTrue("" != response1.updated_date); | 183 | + //Assert.IsTrue(response1.modified_date == null); |
| 184 | + Assert.IsTrue("" != response1.modified_date); | ||
| 208 | 185 | ||
| 209 | - Assert.AreEqual("Administrator", response1.updated_by); | 186 | + Assert.AreEqual("Administrator", response1.modified_by); |
| 210 | 187 | ||
| 211 | Assert.IsTrue(response1.document_id > 0); | 188 | Assert.IsTrue(response1.document_id > 0); |
| 212 | 189 |
ktwebservice/nunit/document_checkout.cs
| @@ -5,24 +5,18 @@ using System.IO; | @@ -5,24 +5,18 @@ using System.IO; | ||
| 5 | namespace MonoTests.KnowledgeTree | 5 | namespace MonoTests.KnowledgeTree |
| 6 | { | 6 | { |
| 7 | [TestFixture] | 7 | [TestFixture] |
| 8 | - public class CheckoutDocumentTest | ||
| 9 | - { | ||
| 10 | - private String _session; | ||
| 11 | - private KnowledgeTreeService _kt; | 8 | + public class CheckoutDocumentTest : KTTest |
| 9 | + { | ||
| 12 | private int _docId; | 10 | private int _docId; |
| 13 | private int _folderId; | 11 | private int _folderId; |
| 14 | private String _filename; | 12 | private String _filename; |
| 15 | - private String _content; | ||
| 16 | - private bool _verbose; | 13 | + private String _content; |
| 17 | 14 | ||
| 18 | 15 | ||
| 19 | [SetUp] | 16 | [SetUp] |
| 20 | public void SetUp() | 17 | public void SetUp() |
| 21 | { | 18 | { |
| 22 | - this._kt = new KnowledgeTreeService(); | ||
| 23 | - kt_response response = this._kt.login("admin","admin","127.0.0.1"); | ||
| 24 | - this._session = response.message; | ||
| 25 | - | 19 | + |
| 26 | this._filename = Helper.isUnix()?"/tmp/kt_unit_test1.txt":"c:\\kt_unit_test1.txt"; | 20 | this._filename = Helper.isUnix()?"/tmp/kt_unit_test1.txt":"c:\\kt_unit_test1.txt"; |
| 27 | 21 | ||
| 28 | String filename = "kt unit test1"; | 22 | String filename = "kt unit test1"; |
| @@ -31,7 +25,7 @@ namespace MonoTests.KnowledgeTree | @@ -31,7 +25,7 @@ namespace MonoTests.KnowledgeTree | ||
| 31 | 25 | ||
| 32 | Helper.writeFile(this._filename, this._content); | 26 | Helper.writeFile(this._filename, this._content); |
| 33 | 27 | ||
| 34 | - this._verbose = false; | 28 | + |
| 35 | 29 | ||
| 36 | this._folderId = 1; | 30 | this._folderId = 1; |
| 37 | 31 | ||
| @@ -56,9 +50,7 @@ namespace MonoTests.KnowledgeTree | @@ -56,9 +50,7 @@ namespace MonoTests.KnowledgeTree | ||
| 56 | if (this._verbose && response.status_code != 0) | 50 | if (this._verbose && response.status_code != 0) |
| 57 | { | 51 | { |
| 58 | System.Console.WriteLine("Could not delete file: " + this._filename); | 52 | System.Console.WriteLine("Could not delete file: " + this._filename); |
| 59 | - } | ||
| 60 | - | ||
| 61 | - this._kt.logout(this._session); | 53 | + } |
| 62 | 54 | ||
| 63 | } | 55 | } |
| 64 | 56 | ||
| @@ -69,12 +61,15 @@ namespace MonoTests.KnowledgeTree | @@ -69,12 +61,15 @@ namespace MonoTests.KnowledgeTree | ||
| 69 | 61 | ||
| 70 | if (this._verbose) System.Console.WriteLine("Checking out document : " + filename); | 62 | if (this._verbose) System.Console.WriteLine("Checking out document : " + filename); |
| 71 | 63 | ||
| 72 | - kt_response response = this._kt.checkout_base64_document(this._session, this._docId, "unit test - going to checkout and then undo", false); | 64 | + kt_document_detail response = this._kt.checkout_base64_document(this._session, this._docId, "unit test - going to checkout and then undo", false); |
| 73 | Assert.AreEqual(0, response.status_code); | 65 | Assert.AreEqual(0, response.status_code); |
| 74 | - | 66 | + Assert.AreEqual("Administrator",response.checked_out_by); |
| 67 | + Assert.IsTrue(null != response.checked_out_date); | ||
| 75 | 68 | ||
| 76 | response = this._kt.undo_document_checkout(this._session, this._docId, "unit test - doing undo"); | 69 | response = this._kt.undo_document_checkout(this._session, this._docId, "unit test - doing undo"); |
| 77 | Assert.AreEqual(0, response.status_code); | 70 | Assert.AreEqual(0, response.status_code); |
| 71 | + Assert.AreEqual("n/a",response.checked_out_by); | ||
| 72 | + Assert.AreEqual("n/a", response.checked_out_date); | ||
| 78 | } | 73 | } |
| 79 | 74 | ||
| 80 | [Test] | 75 | [Test] |
| @@ -84,14 +79,16 @@ namespace MonoTests.KnowledgeTree | @@ -84,14 +79,16 @@ namespace MonoTests.KnowledgeTree | ||
| 84 | 79 | ||
| 85 | if (this._verbose) System.Console.WriteLine("Checking out document : " + filename); | 80 | if (this._verbose) System.Console.WriteLine("Checking out document : " + filename); |
| 86 | 81 | ||
| 87 | - kt_response response = this._kt.checkout_base64_document(this._session, this._docId, "unit test - going to checkout and then checkin", false); | 82 | + kt_document_detail response = this._kt.checkout_base64_document(this._session, this._docId, "unit test - going to checkout and then checkin", false); |
| 88 | Assert.AreEqual(0, response.status_code); | 83 | Assert.AreEqual(0, response.status_code); |
| 84 | + Assert.AreEqual("Administrator",response.checked_out_by); | ||
| 85 | + Assert.IsTrue(null != response.checked_out_date); | ||
| 89 | 86 | ||
| 90 | 87 | ||
| 91 | kt_document_detail checkin = this._kt.checkin_base64_document(this._session, this._docId, filename, "unit test - doing checkin", Helper.ConvertFileToBase64Encoding(this._filename), false); | 88 | kt_document_detail checkin = this._kt.checkin_base64_document(this._session, this._docId, filename, "unit test - doing checkin", Helper.ConvertFileToBase64Encoding(this._filename), false); |
| 92 | Assert.AreEqual(0, checkin.status_code); | 89 | Assert.AreEqual(0, checkin.status_code); |
| 93 | - | ||
| 94 | - //assert - check data checkout | 90 | + Assert.AreEqual("n/a",checkin.checked_out_by); |
| 91 | + Assert.AreEqual("n/a", checkin.checked_out_date); | ||
| 95 | } | 92 | } |
| 96 | 93 | ||
| 97 | [Test] | 94 | [Test] |
| @@ -101,17 +98,20 @@ namespace MonoTests.KnowledgeTree | @@ -101,17 +98,20 @@ namespace MonoTests.KnowledgeTree | ||
| 101 | 98 | ||
| 102 | if (this._verbose) System.Console.WriteLine("Checking out document : " + filename); | 99 | if (this._verbose) System.Console.WriteLine("Checking out document : " + filename); |
| 103 | 100 | ||
| 104 | - kt_response response = this._kt.checkout_document(this._session, this._docId, "unit test - going to checkout and then checkin", false); | 101 | + kt_document_detail response = this._kt.checkout_document(this._session, this._docId, "unit test - going to checkout and then checkin", false); |
| 105 | Assert.AreEqual(0, response.status_code); | 102 | Assert.AreEqual(0, response.status_code); |
| 103 | + Assert.AreEqual("Administrator",response.checked_out_by); | ||
| 104 | + Assert.IsTrue(null != response.checked_out_date); | ||
| 106 | 105 | ||
| 107 | - | ||
| 108 | - FileUploader uploader = new FileUploader("http://ktdms.trunk/ktwebservice/upload.php"); | 106 | + FileUploader uploader = new FileUploader(); |
| 109 | 107 | ||
| 110 | uploader.upload(this._session, this._filename); | 108 | uploader.upload(this._session, this._filename); |
| 111 | String tempname = uploader.getFilename(); | 109 | String tempname = uploader.getFilename(); |
| 112 | 110 | ||
| 113 | kt_document_detail checkin = this._kt.checkin_document(this._session, this._docId, filename, "unit test - doing checkin", tempname, false); | 111 | kt_document_detail checkin = this._kt.checkin_document(this._session, this._docId, filename, "unit test - doing checkin", tempname, false); |
| 114 | - Assert.AreEqual(0, checkin.status_code); | 112 | + Assert.AreEqual(0, checkin.status_code); |
| 113 | + Assert.AreEqual("n/a",checkin.checked_out_by); | ||
| 114 | + Assert.AreEqual("n/a", checkin.checked_out_date); | ||
| 115 | } | 115 | } |
| 116 | 116 | ||
| 117 | 117 |
ktwebservice/nunit/document_copy.cs
0 โ 100644
| 1 | +using NUnit.Framework; | ||
| 2 | +using System; | ||
| 3 | +using System.IO; | ||
| 4 | + | ||
| 5 | +namespace MonoTests.KnowledgeTree | ||
| 6 | +{ | ||
| 7 | + | ||
| 8 | + | ||
| 9 | + [TestFixture] | ||
| 10 | + public class DocumentCopyTest : KTTest | ||
| 11 | + { | ||
| 12 | + private int _folderId; | ||
| 13 | + private Document _doc1; | ||
| 14 | + | ||
| 15 | + | ||
| 16 | + [SetUp] | ||
| 17 | + public void SetUp() | ||
| 18 | + { | ||
| 19 | + this._folderId = 1; | ||
| 20 | + | ||
| 21 | + this._doc1 = new Document(1, this._session, this._kt, this._verbose, false); | ||
| 22 | + this._doc1.createFile(this._folderId); | ||
| 23 | + | ||
| 24 | + | ||
| 25 | + | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + [TearDown] | ||
| 29 | + public void TearDown() | ||
| 30 | + { | ||
| 31 | + this._doc1.deleteFile(); | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + [Test] | ||
| 35 | + public void FindDocumentBeforeCopy() | ||
| 36 | + { | ||
| 37 | + String filename = "Root Folder/test123"; | ||
| 38 | + if (this._verbose) System.Console.WriteLine("Finding document before add: " + filename); | ||
| 39 | + kt_document_detail documentDetail = this._kt.get_document_detail_by_title(this._session, 1, filename, ""); | ||
| 40 | + if (0 == documentDetail.status_code) | ||
| 41 | + { | ||
| 42 | + if (this._verbose) System.Console.WriteLine("Found document - deleting"); | ||
| 43 | + kt_response response = this._kt.delete_document(this._session, documentDetail.document_id, "Delete - cleaning up before add"); | ||
| 44 | + Assert.AreEqual(0, response.status_code); | ||
| 45 | + } | ||
| 46 | + else if (this._verbose) | ||
| 47 | + { | ||
| 48 | + System.Console.WriteLine("document not found. that is ok!"); | ||
| 49 | + } | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + | ||
| 53 | + [Test] | ||
| 54 | + public void CopyTest() | ||
| 55 | + { | ||
| 56 | + kt_document_detail linkresp = this._kt.copy_document(this._session, this._doc1.docId, 1, "copy", "test123", "test123.txt"); | ||
| 57 | + Assert.AreEqual(0, linkresp.status_code); | ||
| 58 | + Assert.AreEqual("test123.txt", linkresp.filename); | ||
| 59 | + Assert.AreEqual("test123", linkresp.title); | ||
| 60 | + | ||
| 61 | + | ||
| 62 | + | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + [Test] | ||
| 66 | + public void FindDocumentAfterCopy() | ||
| 67 | + { | ||
| 68 | + String filename = "Root Folder/test123"; | ||
| 69 | + if (this._verbose) System.Console.WriteLine("Finding document before add: " + filename); | ||
| 70 | + kt_document_detail documentDetail = this._kt.get_document_detail_by_title(this._session, 1, filename, ""); | ||
| 71 | + Assert.AreEqual(0, documentDetail.status_code); | ||
| 72 | + | ||
| 73 | + if (this._verbose) System.Console.WriteLine("Found document - deleting"); | ||
| 74 | + kt_response response = this._kt.delete_document(this._session, documentDetail.document_id, "Delete - cleaning up before add"); | ||
| 75 | + Assert.AreEqual(0, response.status_code); | ||
| 76 | + | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + | ||
| 80 | + | ||
| 81 | + } | ||
| 82 | +} |
ktwebservice/nunit/document_detail.cs
| @@ -5,23 +5,17 @@ using System.IO; | @@ -5,23 +5,17 @@ using System.IO; | ||
| 5 | namespace MonoTests.KnowledgeTree | 5 | namespace MonoTests.KnowledgeTree |
| 6 | { | 6 | { |
| 7 | [TestFixture] | 7 | [TestFixture] |
| 8 | - public class DocumentDetailTest | ||
| 9 | - { | ||
| 10 | - private String _session; | ||
| 11 | - private KnowledgeTreeService _kt; | 8 | + public class DocumentDetailTest : KTTest |
| 9 | + { | ||
| 12 | private int _docId; | 10 | private int _docId; |
| 13 | private int _folderId; | 11 | private int _folderId; |
| 14 | private String _filename; | 12 | private String _filename; |
| 15 | - private String _content; | ||
| 16 | - private bool _verbose; | 13 | + private String _content; |
| 17 | 14 | ||
| 18 | 15 | ||
| 19 | [SetUp] | 16 | [SetUp] |
| 20 | public void SetUp() | 17 | public void SetUp() |
| 21 | - { | ||
| 22 | - this._kt = new KnowledgeTreeService(); | ||
| 23 | - kt_response response = this._kt.login("admin","admin","127.0.0.1"); | ||
| 24 | - this._session = response.message; | 18 | + { |
| 25 | 19 | ||
| 26 | this._filename = Helper.isUnix()?"/tmp/kt_unit_test1.txt":"c:\\kt_unit_test1.txt"; | 20 | this._filename = Helper.isUnix()?"/tmp/kt_unit_test1.txt":"c:\\kt_unit_test1.txt"; |
| 27 | 21 | ||
| @@ -29,10 +23,7 @@ namespace MonoTests.KnowledgeTree | @@ -29,10 +23,7 @@ namespace MonoTests.KnowledgeTree | ||
| 29 | 23 | ||
| 30 | this._content = "hello world!"; | 24 | this._content = "hello world!"; |
| 31 | 25 | ||
| 32 | - Helper.writeFile(this._filename, this._content); | ||
| 33 | - | ||
| 34 | - this._verbose = false; | ||
| 35 | - | 26 | + Helper.writeFile(this._filename, this._content); |
| 36 | this._folderId = 1; | 27 | this._folderId = 1; |
| 37 | 28 | ||
| 38 | kt_document_detail response1 = this._kt.add_base64_document(this._session, this._folderId, filename, this._filename, "Default", Helper.ConvertFileToBase64Encoding(this._filename)); | 29 | kt_document_detail response1 = this._kt.add_base64_document(this._session, this._folderId, filename, this._filename, "Default", Helper.ConvertFileToBase64Encoding(this._filename)); |
| @@ -56,9 +47,7 @@ namespace MonoTests.KnowledgeTree | @@ -56,9 +47,7 @@ namespace MonoTests.KnowledgeTree | ||
| 56 | if (this._verbose && response.status_code != 0) | 47 | if (this._verbose && response.status_code != 0) |
| 57 | { | 48 | { |
| 58 | System.Console.WriteLine("Could not delete file: " + this._filename); | 49 | System.Console.WriteLine("Could not delete file: " + this._filename); |
| 59 | - } | ||
| 60 | - | ||
| 61 | - this._kt.logout(this._session); | 50 | + } |
| 62 | 51 | ||
| 63 | } | 52 | } |
| 64 | 53 |
ktwebservice/nunit/document_download.cs
| @@ -8,40 +8,25 @@ namespace MonoTests.KnowledgeTree | @@ -8,40 +8,25 @@ namespace MonoTests.KnowledgeTree | ||
| 8 | 8 | ||
| 9 | 9 | ||
| 10 | [TestFixture] | 10 | [TestFixture] |
| 11 | - public class DocumentSystemMetadataTest | 11 | + public class DocumentSystemMetadataTest : KTTest |
| 12 | { | 12 | { |
| 13 | - private String _session; | ||
| 14 | - private KnowledgeTreeService _kt; | ||
| 15 | private int _folderId; | 13 | private int _folderId; |
| 16 | - private bool _verbose; | ||
| 17 | private Document _doc1; | 14 | private Document _doc1; |
| 18 | 15 | ||
| 19 | 16 | ||
| 20 | [SetUp] | 17 | [SetUp] |
| 21 | public void SetUp() | 18 | public void SetUp() |
| 22 | { | 19 | { |
| 23 | - this._kt = new KnowledgeTreeService(); | ||
| 24 | - kt_response response = this._kt.login("admin","admin","127.0.0.1"); | ||
| 25 | - this._session = response.message; | ||
| 26 | - | ||
| 27 | this._folderId = 1; | 20 | this._folderId = 1; |
| 28 | 21 | ||
| 29 | - | ||
| 30 | this._doc1 = new Document(1, this._session, this._kt, this._verbose,false); | 22 | this._doc1 = new Document(1, this._session, this._kt, this._verbose,false); |
| 31 | this._doc1.createFile(this._folderId); | 23 | this._doc1.createFile(this._folderId); |
| 32 | - | ||
| 33 | - | ||
| 34 | - this._verbose = true; | ||
| 35 | - | ||
| 36 | } | 24 | } |
| 37 | 25 | ||
| 38 | [TearDown] | 26 | [TearDown] |
| 39 | public void TearDown() | 27 | public void TearDown() |
| 40 | { | 28 | { |
| 41 | this._doc1.deleteFile(); | 29 | this._doc1.deleteFile(); |
| 42 | - | ||
| 43 | - this._kt.logout(this._session); | ||
| 44 | - | ||
| 45 | } | 30 | } |
| 46 | 31 | ||
| 47 | [Test] | 32 | [Test] |
ktwebservice/nunit/document_history.cs
| @@ -5,36 +5,24 @@ using System.IO; | @@ -5,36 +5,24 @@ using System.IO; | ||
| 5 | namespace MonoTests.KnowledgeTree | 5 | namespace MonoTests.KnowledgeTree |
| 6 | { | 6 | { |
| 7 | [TestFixture] | 7 | [TestFixture] |
| 8 | - public class DocumentHistoryTest | 8 | + public class DocumentHistoryTest : KTTest |
| 9 | { | 9 | { |
| 10 | - private String _session; | ||
| 11 | - private KnowledgeTreeService _kt; | ||
| 12 | private int _folderId; | 10 | private int _folderId; |
| 13 | - private bool _verbose; | ||
| 14 | private Document _doc1; | 11 | private Document _doc1; |
| 15 | 12 | ||
| 16 | [SetUp] | 13 | [SetUp] |
| 17 | public void SetUp() | 14 | public void SetUp() |
| 18 | { | 15 | { |
| 19 | - this._kt = new KnowledgeTreeService(); | ||
| 20 | - kt_response response = this._kt.login("admin","admin","127.0.0.1"); | ||
| 21 | - this._session = response.message; | ||
| 22 | - | ||
| 23 | this._folderId = 1; | 16 | this._folderId = 1; |
| 24 | 17 | ||
| 25 | this._doc1 = new Document(1, this._session, this._kt, this._verbose,false); | 18 | this._doc1 = new Document(1, this._session, this._kt, this._verbose,false); |
| 26 | this._doc1.createFile(this._folderId); | 19 | this._doc1.createFile(this._folderId); |
| 27 | - | ||
| 28 | - this._verbose = true; | ||
| 29 | - | ||
| 30 | } | 20 | } |
| 31 | 21 | ||
| 32 | [TearDown] | 22 | [TearDown] |
| 33 | public void TearDown() | 23 | public void TearDown() |
| 34 | { | 24 | { |
| 35 | this._doc1.deleteFile(); | 25 | this._doc1.deleteFile(); |
| 36 | - | ||
| 37 | - this._kt.logout(this._session); | ||
| 38 | } | 26 | } |
| 39 | 27 | ||
| 40 | [Test] | 28 | [Test] |
ktwebservice/nunit/document_links.cs
| @@ -7,12 +7,9 @@ namespace MonoTests.KnowledgeTree | @@ -7,12 +7,9 @@ namespace MonoTests.KnowledgeTree | ||
| 7 | 7 | ||
| 8 | 8 | ||
| 9 | [TestFixture] | 9 | [TestFixture] |
| 10 | - public class DocumentLinkTest | 10 | + public class DocumentLinkTest : KTTest |
| 11 | { | 11 | { |
| 12 | - private String _session; | ||
| 13 | - private KnowledgeTreeService _kt; | ||
| 14 | private int _folderId; | 12 | private int _folderId; |
| 15 | - private bool _verbose; | ||
| 16 | private Document _doc1; | 13 | private Document _doc1; |
| 17 | private Document _doc2; | 14 | private Document _doc2; |
| 18 | 15 | ||
| @@ -20,21 +17,12 @@ namespace MonoTests.KnowledgeTree | @@ -20,21 +17,12 @@ namespace MonoTests.KnowledgeTree | ||
| 20 | [SetUp] | 17 | [SetUp] |
| 21 | public void SetUp() | 18 | public void SetUp() |
| 22 | { | 19 | { |
| 23 | - this._kt = new KnowledgeTreeService(); | ||
| 24 | - kt_response response = this._kt.login("admin","admin","127.0.0.1"); | ||
| 25 | - this._session = response.message; | ||
| 26 | - | ||
| 27 | this._folderId = 1; | 20 | this._folderId = 1; |
| 28 | 21 | ||
| 29 | - | ||
| 30 | this._doc1 = new Document(1, this._session, this._kt, this._verbose, false); | 22 | this._doc1 = new Document(1, this._session, this._kt, this._verbose, false); |
| 31 | this._doc1.createFile(this._folderId); | 23 | this._doc1.createFile(this._folderId); |
| 32 | this._doc2 = new Document(2, this._session, this._kt, this._verbose, false); | 24 | this._doc2 = new Document(2, this._session, this._kt, this._verbose, false); |
| 33 | this._doc2.createFile(this._folderId); | 25 | this._doc2.createFile(this._folderId); |
| 34 | - | ||
| 35 | - | ||
| 36 | - this._verbose = true; | ||
| 37 | - | ||
| 38 | } | 26 | } |
| 39 | 27 | ||
| 40 | [TearDown] | 28 | [TearDown] |
| @@ -42,9 +30,6 @@ namespace MonoTests.KnowledgeTree | @@ -42,9 +30,6 @@ namespace MonoTests.KnowledgeTree | ||
| 42 | { | 30 | { |
| 43 | this._doc1.deleteFile(); | 31 | this._doc1.deleteFile(); |
| 44 | this._doc2.deleteFile(); | 32 | this._doc2.deleteFile(); |
| 45 | - | ||
| 46 | - this._kt.logout(this._session); | ||
| 47 | - | ||
| 48 | } | 33 | } |
| 49 | 34 | ||
| 50 | [Test] | 35 | [Test] |
ktwebservice/nunit/document_metadata.cs
| @@ -5,25 +5,17 @@ using System.IO; | @@ -5,25 +5,17 @@ using System.IO; | ||
| 5 | namespace MonoTests.KnowledgeTree | 5 | namespace MonoTests.KnowledgeTree |
| 6 | { | 6 | { |
| 7 | [TestFixture] | 7 | [TestFixture] |
| 8 | - public class DocumentMetadataTest | 8 | + public class DocumentMetadataTest : KTTest |
| 9 | { | 9 | { |
| 10 | - private String _session; | ||
| 11 | - private KnowledgeTreeService _kt; | ||
| 12 | private int _docId; | 10 | private int _docId; |
| 13 | private int _folderId; | 11 | private int _folderId; |
| 14 | private String _filename; | 12 | private String _filename; |
| 15 | private String _content; | 13 | private String _content; |
| 16 | - private bool _verbose; | ||
| 17 | 14 | ||
| 18 | 15 | ||
| 19 | [SetUp] | 16 | [SetUp] |
| 20 | public void SetUp() | 17 | public void SetUp() |
| 21 | { | 18 | { |
| 22 | - this._kt = new KnowledgeTreeService(); | ||
| 23 | - | ||
| 24 | - kt_response response = this._kt.login("admin","admin","127.0.0.1"); | ||
| 25 | - this._session = response.message; | ||
| 26 | - | ||
| 27 | this._filename = Helper.isUnix()?"/tmp/kt_unit_test1.txt":"c:\\kt_unit_test1.txt"; | 19 | this._filename = Helper.isUnix()?"/tmp/kt_unit_test1.txt":"c:\\kt_unit_test1.txt"; |
| 28 | 20 | ||
| 29 | String filename = "kt unit test1"; | 21 | String filename = "kt unit test1"; |
| @@ -32,8 +24,6 @@ namespace MonoTests.KnowledgeTree | @@ -32,8 +24,6 @@ namespace MonoTests.KnowledgeTree | ||
| 32 | 24 | ||
| 33 | Helper.writeFile(this._filename, this._content); | 25 | Helper.writeFile(this._filename, this._content); |
| 34 | 26 | ||
| 35 | - this._verbose = false; | ||
| 36 | - | ||
| 37 | this._folderId = 1; | 27 | this._folderId = 1; |
| 38 | 28 | ||
| 39 | kt_document_detail response1 = this._kt.add_base64_document(this._session, this._folderId, filename, this._filename, "Default", Helper.ConvertFileToBase64Encoding(this._filename)); | 29 | kt_document_detail response1 = this._kt.add_base64_document(this._session, this._folderId, filename, this._filename, "Default", Helper.ConvertFileToBase64Encoding(this._filename)); |
| @@ -58,9 +48,6 @@ namespace MonoTests.KnowledgeTree | @@ -58,9 +48,6 @@ namespace MonoTests.KnowledgeTree | ||
| 58 | { | 48 | { |
| 59 | System.Console.WriteLine("Could not delete file: " + this._filename); | 49 | System.Console.WriteLine("Could not delete file: " + this._filename); |
| 60 | } | 50 | } |
| 61 | - | ||
| 62 | - this._kt.logout(this._session); | ||
| 63 | - | ||
| 64 | } | 51 | } |
| 65 | 52 | ||
| 66 | [Test] | 53 | [Test] |
ktwebservice/nunit/document_owner.cs
| @@ -5,38 +5,24 @@ using System.IO; | @@ -5,38 +5,24 @@ using System.IO; | ||
| 5 | namespace MonoTests.KnowledgeTree | 5 | namespace MonoTests.KnowledgeTree |
| 6 | { | 6 | { |
| 7 | [TestFixture] | 7 | [TestFixture] |
| 8 | - public class DocumentOwnerTest | 8 | + public class DocumentOwnerTest : KTTest |
| 9 | { | 9 | { |
| 10 | - private String _session; | ||
| 11 | - private KnowledgeTreeService _kt; | ||
| 12 | private int _folderId; | 10 | private int _folderId; |
| 13 | - private bool _verbose; | ||
| 14 | private Document _doc1; | 11 | private Document _doc1; |
| 15 | 12 | ||
| 16 | [SetUp] | 13 | [SetUp] |
| 17 | public void SetUp() | 14 | public void SetUp() |
| 18 | { | 15 | { |
| 19 | - this._kt = new KnowledgeTreeService(); | ||
| 20 | - kt_response response = this._kt.login("admin","admin","127.0.0.1"); | ||
| 21 | - this._session = response.message; | ||
| 22 | - | ||
| 23 | this._folderId = 1; | 16 | this._folderId = 1; |
| 24 | 17 | ||
| 25 | - | ||
| 26 | this._doc1 = new Document(1, this._session, this._kt, this._verbose, false); | 18 | this._doc1 = new Document(1, this._session, this._kt, this._verbose, false); |
| 27 | this._doc1.createFile(this._folderId); | 19 | this._doc1.createFile(this._folderId); |
| 28 | - | ||
| 29 | - this._verbose = true; | ||
| 30 | - | ||
| 31 | } | 20 | } |
| 32 | 21 | ||
| 33 | [TearDown] | 22 | [TearDown] |
| 34 | public void TearDown() | 23 | public void TearDown() |
| 35 | { | 24 | { |
| 36 | this._doc1.deleteFile(); | 25 | this._doc1.deleteFile(); |
| 37 | - | ||
| 38 | - this._kt.logout(this._session); | ||
| 39 | - | ||
| 40 | } | 26 | } |
| 41 | 27 | ||
| 42 | [Test] | 28 | [Test] |
ktwebservice/nunit/document_rename.cs
| @@ -5,36 +5,24 @@ using System.IO; | @@ -5,36 +5,24 @@ using System.IO; | ||
| 5 | namespace MonoTests.KnowledgeTree | 5 | namespace MonoTests.KnowledgeTree |
| 6 | { | 6 | { |
| 7 | [TestFixture] | 7 | [TestFixture] |
| 8 | - public class DocumentRenameTest | 8 | + public class DocumentRenameTest : KTTest |
| 9 | { | 9 | { |
| 10 | - private String _session; | ||
| 11 | - private KnowledgeTreeService _kt; | ||
| 12 | private int _folderId; | 10 | private int _folderId; |
| 13 | - private bool _verbose; | ||
| 14 | private Document _doc1; | 11 | private Document _doc1; |
| 15 | 12 | ||
| 16 | [SetUp] | 13 | [SetUp] |
| 17 | public void SetUp() | 14 | public void SetUp() |
| 18 | { | 15 | { |
| 19 | - this._kt = new KnowledgeTreeService(); | ||
| 20 | - kt_response response = this._kt.login("admin","admin","127.0.0.1"); | ||
| 21 | - this._session = response.message; | ||
| 22 | - | ||
| 23 | this._folderId = 1; | 16 | this._folderId = 1; |
| 24 | 17 | ||
| 25 | this._doc1 = new Document(1, this._session, this._kt, this._verbose,false); | 18 | this._doc1 = new Document(1, this._session, this._kt, this._verbose,false); |
| 26 | this._doc1.createFile(this._folderId); | 19 | this._doc1.createFile(this._folderId); |
| 27 | - | ||
| 28 | - this._verbose = true; | ||
| 29 | - | ||
| 30 | } | 20 | } |
| 31 | 21 | ||
| 32 | [TearDown] | 22 | [TearDown] |
| 33 | public void TearDown() | 23 | public void TearDown() |
| 34 | { | 24 | { |
| 35 | this._doc1.deleteFile(); | 25 | this._doc1.deleteFile(); |
| 36 | - | ||
| 37 | - this._kt.logout(this._session); | ||
| 38 | } | 26 | } |
| 39 | 27 | ||
| 40 | [Test] | 28 | [Test] |
ktwebservice/nunit/document_system_metadata.cs
| @@ -7,12 +7,9 @@ namespace MonoTests.KnowledgeTree | @@ -7,12 +7,9 @@ namespace MonoTests.KnowledgeTree | ||
| 7 | 7 | ||
| 8 | 8 | ||
| 9 | [TestFixture] | 9 | [TestFixture] |
| 10 | - public class DocumentSystemMetadataTest | 10 | + public class DocumentSystemMetadataTest : KTTest |
| 11 | { | 11 | { |
| 12 | - private String _session; | ||
| 13 | - private KnowledgeTreeService _kt; | ||
| 14 | private int _folderId; | 12 | private int _folderId; |
| 15 | - private bool _verbose; | ||
| 16 | private Document _doc1; | 13 | private Document _doc1; |
| 17 | private Document _doc2; | 14 | private Document _doc2; |
| 18 | 15 | ||
| @@ -20,20 +17,12 @@ namespace MonoTests.KnowledgeTree | @@ -20,20 +17,12 @@ namespace MonoTests.KnowledgeTree | ||
| 20 | [SetUp] | 17 | [SetUp] |
| 21 | public void SetUp() | 18 | public void SetUp() |
| 22 | { | 19 | { |
| 23 | - this._kt = new KnowledgeTreeService(); | ||
| 24 | - kt_response response = this._kt.login("admin","admin","127.0.0.1"); | ||
| 25 | - this._session = response.message; | ||
| 26 | - | ||
| 27 | this._folderId = 1; | 20 | this._folderId = 1; |
| 28 | 21 | ||
| 29 | 22 | ||
| 30 | this._doc1 = new Document(1, this._session, this._kt, this._verbose,false); | 23 | this._doc1 = new Document(1, this._session, this._kt, this._verbose,false); |
| 31 | this._doc1.createFile(this._folderId); | 24 | this._doc1.createFile(this._folderId); |
| 32 | this._doc2 = new Document(2, this._session, this._kt, this._verbose,true); | 25 | this._doc2 = new Document(2, this._session, this._kt, this._verbose,true); |
| 33 | - | ||
| 34 | - | ||
| 35 | - this._verbose = true; | ||
| 36 | - | ||
| 37 | } | 26 | } |
| 38 | 27 | ||
| 39 | [TearDown] | 28 | [TearDown] |
| @@ -41,12 +30,9 @@ namespace MonoTests.KnowledgeTree | @@ -41,12 +30,9 @@ namespace MonoTests.KnowledgeTree | ||
| 41 | { | 30 | { |
| 42 | this._doc1.deleteFile(); | 31 | this._doc1.deleteFile(); |
| 43 | this._doc2.deleteFile(); | 32 | this._doc2.deleteFile(); |
| 44 | - | ||
| 45 | - this._kt.logout(this._session); | ||
| 46 | - | ||
| 47 | } | 33 | } |
| 48 | 34 | ||
| 49 | - [Test] | 35 | +// [Test] |
| 50 | public void UpdateDocumentMetadataTest() | 36 | public void UpdateDocumentMetadataTest() |
| 51 | { | 37 | { |
| 52 | 38 | ||
| @@ -64,13 +50,16 @@ namespace MonoTests.KnowledgeTree | @@ -64,13 +50,16 @@ namespace MonoTests.KnowledgeTree | ||
| 64 | fs[0].fields[2].name = "Media Type"; | 50 | fs[0].fields[2].name = "Media Type"; |
| 65 | fs[0].fields[2].value = "Text"; | 51 | fs[0].fields[2].value = "Text"; |
| 66 | 52 | ||
| 67 | - kt_sysdata_item[] sysdata = new kt_sysdata_item[2]; | 53 | + kt_sysdata_item[] sysdata = new kt_sysdata_item[3]; |
| 68 | sysdata[0] = new kt_sysdata_item(); | 54 | sysdata[0] = new kt_sysdata_item(); |
| 69 | sysdata[0].name = "created_by"; | 55 | sysdata[0].name = "created_by"; |
| 70 | sysdata[0].value = "Anonymous"; | 56 | sysdata[0].value = "Anonymous"; |
| 71 | sysdata[1] = new kt_sysdata_item(); | 57 | sysdata[1] = new kt_sysdata_item(); |
| 72 | sysdata[1].name = "created_date"; | 58 | sysdata[1].name = "created_date"; |
| 73 | sysdata[1].value = "2007-01-17"; | 59 | sysdata[1].value = "2007-01-17"; |
| 60 | + sysdata[2] = new kt_sysdata_item(); | ||
| 61 | + sysdata[2].name = "modified_by"; | ||
| 62 | + sysdata[2].value = "admin"; | ||
| 74 | 63 | ||
| 75 | 64 | ||
| 76 | kt_document_detail update_resp = this._kt.update_document_metadata(this._session, this._doc1.docId, fs, sysdata); | 65 | kt_document_detail update_resp = this._kt.update_document_metadata(this._session, this._doc1.docId, fs, sysdata); |
| @@ -88,9 +77,11 @@ namespace MonoTests.KnowledgeTree | @@ -88,9 +77,11 @@ namespace MonoTests.KnowledgeTree | ||
| 88 | 77 | ||
| 89 | Assert.AreEqual("Anonymous", update_resp.created_by); | 78 | Assert.AreEqual("Anonymous", update_resp.created_by); |
| 90 | Assert.AreEqual("2007-01-17 00:00:00", update_resp.created_date); | 79 | Assert.AreEqual("2007-01-17 00:00:00", update_resp.created_date); |
| 80 | + Assert.AreEqual("Administrator", update_resp.modified_by); | ||
| 81 | + Assert.AreEqual("2007-01-17 00:00:00", update_resp.created_date); | ||
| 91 | } | 82 | } |
| 92 | 83 | ||
| 93 | - [Test] | 84 | +// [Test] |
| 94 | public void AddSmallDocumentWithMetadataTest() | 85 | public void AddSmallDocumentWithMetadataTest() |
| 95 | { | 86 | { |
| 96 | kt_metadata_fieldset[] fs = new kt_metadata_fieldset[1]; | 87 | kt_metadata_fieldset[] fs = new kt_metadata_fieldset[1]; |
| @@ -134,7 +125,7 @@ namespace MonoTests.KnowledgeTree | @@ -134,7 +125,7 @@ namespace MonoTests.KnowledgeTree | ||
| 134 | Assert.AreEqual("2007-01-17 00:00:00", update_resp.created_date); | 125 | Assert.AreEqual("2007-01-17 00:00:00", update_resp.created_date); |
| 135 | } | 126 | } |
| 136 | 127 | ||
| 137 | - [Test] | 128 | +// [Test] |
| 138 | public void CheckinSmallDocumentWithMetadataTest() | 129 | public void CheckinSmallDocumentWithMetadataTest() |
| 139 | { | 130 | { |
| 140 | kt_metadata_fieldset[] fs = new kt_metadata_fieldset[1]; | 131 | kt_metadata_fieldset[] fs = new kt_metadata_fieldset[1]; |
| @@ -159,7 +150,7 @@ namespace MonoTests.KnowledgeTree | @@ -159,7 +150,7 @@ namespace MonoTests.KnowledgeTree | ||
| 159 | sysdata[1].name = "created_date"; | 150 | sysdata[1].name = "created_date"; |
| 160 | sysdata[1].value = "2007-01-17"; | 151 | sysdata[1].value = "2007-01-17"; |
| 161 | 152 | ||
| 162 | - kt_response resp = this._kt.checkout_base64_document(this._session, this._doc1.docId, "test checkin", false); | 153 | + kt_document_detail resp = this._kt.checkout_base64_document(this._session, this._doc1.docId, "test checkin", false); |
| 163 | Assert.AreEqual(0, resp.status_code); | 154 | Assert.AreEqual(0, resp.status_code); |
| 164 | 155 | ||
| 165 | 156 | ||
| @@ -181,7 +172,83 @@ namespace MonoTests.KnowledgeTree | @@ -181,7 +172,83 @@ namespace MonoTests.KnowledgeTree | ||
| 181 | Assert.AreEqual("Anonymous", update_resp.created_by); | 172 | Assert.AreEqual("Anonymous", update_resp.created_by); |
| 182 | Assert.AreEqual("2007-01-17 00:00:00", update_resp.created_date); | 173 | Assert.AreEqual("2007-01-17 00:00:00", update_resp.created_date); |
| 183 | } | 174 | } |
| 175 | + | ||
| 176 | + [Test] | ||
| 177 | + public void AddDocumentWithMetadataTest() | ||
| 178 | + { | ||
| 179 | + kt_metadata_fieldset[] fs = new kt_metadata_fieldset[1]; | ||
| 180 | + fs[0] = new kt_metadata_fieldset(); | ||
| 181 | + fs[0].fieldset = "General information"; | ||
| 182 | + fs[0].fields = new kt_metadata_field[3]; | ||
| 183 | + fs[0].fields[0] = new kt_metadata_field(); | ||
| 184 | + fs[0].fields[0].name = "Document Author"; | ||
| 185 | + fs[0].fields[0].value = "Joe Soap"; | ||
| 186 | + fs[0].fields[1] = new kt_metadata_field(); | ||
| 187 | + fs[0].fields[1].name = "Category"; | ||
| 188 | + fs[0].fields[1].value = "Technical"; | ||
| 189 | + fs[0].fields[2] = new kt_metadata_field(); | ||
| 190 | + fs[0].fields[2].name = "Media Type"; | ||
| 191 | + fs[0].fields[2].value = "Text"; | ||
| 192 | + | ||
| 193 | + kt_sysdata_item[] sysdata = new kt_sysdata_item[2]; | ||
| 194 | + sysdata[0] = new kt_sysdata_item(); | ||
| 195 | + sysdata[0].name = "created_by"; | ||
| 196 | + sysdata[0].value = "Anonymous"; | ||
| 197 | + sysdata[1] = new kt_sysdata_item(); | ||
| 198 | + sysdata[1].name = "created_date"; | ||
| 199 | + sysdata[1].value = "2007-01-17"; | ||
| 200 | + | ||
| 201 | + | ||
| 202 | + | ||
| 203 | + this._doc2.local = true; | ||
| 204 | + this._doc2.createFile(this._folderId); | ||
| 205 | + | ||
| 206 | + | ||
| 207 | + FileUploader uploader = new FileUploader( ); | ||
| 208 | + | ||
| 209 | + uploader.upload(this._session, this._doc2.filename); | ||
| 210 | + | ||
| 211 | + System.Console.WriteLine("uploaded: " + uploader.filename); | ||
| 212 | + kt_document_detail response1 = this._kt.add_document_with_metadata(this._session, this._folderId, this._doc2.title, this._doc2.filename, "Default", uploader.filename,fs, sysdata); | ||
| 213 | + | ||
| 214 | + Assert.AreEqual(0, response1.status_code); | ||
| 215 | + } | ||
| 184 | 216 | ||
| 217 | + [Test] | ||
| 218 | + public void CheckinDocumentWithMetadataTest() | ||
| 219 | + { | ||
| 220 | + kt_metadata_fieldset[] fs = new kt_metadata_fieldset[1]; | ||
| 221 | + fs[0] = new kt_metadata_fieldset(); | ||
| 222 | + fs[0].fieldset = "General information"; | ||
| 223 | + fs[0].fields = new kt_metadata_field[3]; | ||
| 224 | + fs[0].fields[0] = new kt_metadata_field(); | ||
| 225 | + fs[0].fields[0].name = "Document Author"; | ||
| 226 | + fs[0].fields[0].value = "Joe Soap"; | ||
| 227 | + fs[0].fields[1] = new kt_metadata_field(); | ||
| 228 | + fs[0].fields[1].name = "Category"; | ||
| 229 | + fs[0].fields[1].value = "Technical"; | ||
| 230 | + fs[0].fields[2] = new kt_metadata_field(); | ||
| 231 | + fs[0].fields[2].name = "Media Type"; | ||
| 232 | + fs[0].fields[2].value = "Text"; | ||
| 233 | + | ||
| 234 | + kt_sysdata_item[] sysdata = new kt_sysdata_item[2]; | ||
| 235 | + sysdata[0] = new kt_sysdata_item(); | ||
| 236 | + sysdata[0].name = "created_by"; | ||
| 237 | + sysdata[0].value = "Anonymous"; | ||
| 238 | + sysdata[1] = new kt_sysdata_item(); | ||
| 239 | + sysdata[1].name = "created_date"; | ||
| 240 | + sysdata[1].value = "2007-01-17"; | ||
| 241 | + | ||
| 242 | + kt_document_detail resp = this._kt.checkout_base64_document(this._session, this._doc1.docId, "test checkin", false); | ||
| 243 | + Assert.AreEqual(0, resp.status_code); | ||
| 244 | + | ||
| 245 | + FileUploader uploader = new FileUploader( ); | ||
| 246 | + | ||
| 247 | + uploader.upload(this._session, this._doc1.filename); | ||
| 248 | + | ||
| 249 | + kt_document_detail update_resp = this._kt.checkin_document(this._session, this._doc1.docId, this._doc1.filename, "unit test - doing checkin", uploader.filename, false); | ||
| 250 | + Assert.AreEqual(0, update_resp.status_code); | ||
| 251 | + } | ||
| 185 | 252 | ||
| 186 | } | 253 | } |
| 187 | } | 254 | } |
ktwebservice/nunit/document_type.cs
| @@ -5,21 +5,14 @@ using System.IO; | @@ -5,21 +5,14 @@ using System.IO; | ||
| 5 | namespace MonoTests.KnowledgeTree | 5 | namespace MonoTests.KnowledgeTree |
| 6 | { | 6 | { |
| 7 | [TestFixture] | 7 | [TestFixture] |
| 8 | - public class DocumentOwnerTest | 8 | + public class DocumentOwnerTest : KTTest |
| 9 | { | 9 | { |
| 10 | - private String _session; | ||
| 11 | - private KnowledgeTreeService _kt; | ||
| 12 | - private int _folderId; | ||
| 13 | - private bool _verbose; | 10 | + private int _folderId; |
| 14 | private Document _doc1; | 11 | private Document _doc1; |
| 15 | 12 | ||
| 16 | [SetUp] | 13 | [SetUp] |
| 17 | public void SetUp() | 14 | public void SetUp() |
| 18 | { | 15 | { |
| 19 | - this._kt = new KnowledgeTreeService(); | ||
| 20 | - kt_response response = this._kt.login("admin","admin","127.0.0.1"); | ||
| 21 | - this._session = response.message; | ||
| 22 | - | ||
| 23 | this._folderId = 1; | 16 | this._folderId = 1; |
| 24 | 17 | ||
| 25 | 18 | ||
| @@ -34,9 +27,6 @@ namespace MonoTests.KnowledgeTree | @@ -34,9 +27,6 @@ namespace MonoTests.KnowledgeTree | ||
| 34 | public void TearDown() | 27 | public void TearDown() |
| 35 | { | 28 | { |
| 36 | this._doc1.deleteFile(); | 29 | this._doc1.deleteFile(); |
| 37 | - | ||
| 38 | - this._kt.logout(this._session); | ||
| 39 | - | ||
| 40 | } | 30 | } |
| 41 | 31 | ||
| 42 | [Test] | 32 | [Test] |
ktwebservice/nunit/document_workflow.cs
| @@ -5,35 +5,24 @@ using System.IO; | @@ -5,35 +5,24 @@ using System.IO; | ||
| 5 | namespace MonoTests.KnowledgeTree | 5 | namespace MonoTests.KnowledgeTree |
| 6 | { | 6 | { |
| 7 | [TestFixture] | 7 | [TestFixture] |
| 8 | - public class WorkflowTest | ||
| 9 | - { | ||
| 10 | - private String _session; | ||
| 11 | - private KnowledgeTreeService _kt; | ||
| 12 | - private int _folderId; | ||
| 13 | - private bool _verbose; | 8 | + public class WorkflowTest : KTTest |
| 9 | + { | ||
| 10 | + private int _folderId; | ||
| 14 | private Document _doc1; | 11 | private Document _doc1; |
| 15 | 12 | ||
| 16 | [SetUp] | 13 | [SetUp] |
| 17 | public void SetUp() | 14 | public void SetUp() |
| 18 | - { | ||
| 19 | - this._kt = new KnowledgeTreeService(); | ||
| 20 | - kt_response response = this._kt.login("admin","admin","127.0.0.1"); | ||
| 21 | - this._session = response.message; | ||
| 22 | - | ||
| 23 | - this._folderId = 1; | ||
| 24 | - | ||
| 25 | - | 15 | + { |
| 16 | + this._folderId = 1; | ||
| 17 | + | ||
| 26 | this._doc1 = new Document(1, this._session, this._kt, this._verbose, false); | 18 | this._doc1 = new Document(1, this._session, this._kt, this._verbose, false); |
| 27 | - this._doc1.createFile(this._folderId); | ||
| 28 | - | ||
| 29 | - this._verbose = true; | 19 | + this._doc1.createFile(this._folderId); |
| 30 | } | 20 | } |
| 31 | 21 | ||
| 32 | [TearDown] | 22 | [TearDown] |
| 33 | public void TearDown() | 23 | public void TearDown() |
| 34 | { | 24 | { |
| 35 | - this._doc1.deleteFile(); | ||
| 36 | - this._kt.logout(this._session); | 25 | + this._doc1.deleteFile(); |
| 37 | } | 26 | } |
| 38 | 27 | ||
| 39 | [Test] | 28 | [Test] |
ktwebservice/nunit/folder.cs
| @@ -5,28 +5,20 @@ using System.IO; | @@ -5,28 +5,20 @@ using System.IO; | ||
| 5 | namespace MonoTests.KnowledgeTree | 5 | namespace MonoTests.KnowledgeTree |
| 6 | { | 6 | { |
| 7 | [TestFixture] | 7 | [TestFixture] |
| 8 | - public class FolderTest | 8 | + public class FolderTest : KTTest |
| 9 | { | 9 | { |
| 10 | - | ||
| 11 | - private String _session; | ||
| 12 | - private KnowledgeTreeService _kt; | 10 | + |
| 13 | private int _folder_id; | 11 | private int _folder_id; |
| 14 | private int _subfolder_id; | 12 | private int _subfolder_id; |
| 15 | 13 | ||
| 16 | [SetUp] | 14 | [SetUp] |
| 17 | public void SetUp() | 15 | public void SetUp() |
| 18 | { | 16 | { |
| 19 | - this._kt = new KnowledgeTreeService(); | ||
| 20 | - kt_response response = this._kt.login("admin","admin","127.0.0.1"); | ||
| 21 | - this._session = response.message; | ||
| 22 | - | ||
| 23 | } | 17 | } |
| 24 | 18 | ||
| 25 | [TearDown] | 19 | [TearDown] |
| 26 | public void TearDown() | 20 | public void TearDown() |
| 27 | - { | ||
| 28 | - | ||
| 29 | - this._kt.logout(this._session); | 21 | + { |
| 30 | } | 22 | } |
| 31 | 23 | ||
| 32 | [Test] | 24 | [Test] |
ktwebservice/nunit/helper.cs
| 1 | using System; | 1 | using System; |
| 2 | using System.Text; | 2 | using System.Text; |
| 3 | using System.Net; | 3 | using System.Net; |
| 4 | -using System.IO; | 4 | +using System.IO; |
| 5 | +using System.Collections; | ||
| 5 | 6 | ||
| 6 | namespace MonoTests.KnowledgeTree | 7 | namespace MonoTests.KnowledgeTree |
| 7 | { | 8 | { |
| 9 | + | ||
| 10 | + | ||
| 11 | + | ||
| 12 | + [System.Web.Services.WebServiceBinding(Name="KnowledgeTreePort", Namespace="urn:KnowledgeTree")] | ||
| 13 | + public class KTWebService : KnowledgeTreeService | ||
| 14 | + { | ||
| 15 | + public KTWebService() : base() | ||
| 16 | + { | ||
| 17 | + this.Url = Environment.GetEnvironmentVariable("KT_ROOT_URL") + "/ktwebservice/webservice.php"; | ||
| 18 | + } | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + public class KTTest | ||
| 22 | + { | ||
| 23 | + protected KTWebService _kt; | ||
| 24 | + protected String _session; | ||
| 25 | + protected bool _verbose; | ||
| 26 | + | ||
| 27 | + public KTTest() | ||
| 28 | + { | ||
| 29 | + this._kt = new KTWebService(); | ||
| 30 | + kt_response response = this._kt.login("admin","admin","127.0.0.1"); | ||
| 31 | + this._session = response.message; | ||
| 32 | + this._verbose = false; | ||
| 33 | + | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + ~KTTest() | ||
| 37 | + { | ||
| 38 | + this._kt.logout(this._session); | ||
| 39 | + } | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + | ||
| 43 | + | ||
| 8 | public class FileUploader | 44 | public class FileUploader |
| 9 | { | 45 | { |
| 10 | private String boundary; | 46 | private String boundary; |
| 11 | private String uri; | 47 | private String uri; |
| 12 | - private String filename; | 48 | + public String filename; |
| 13 | 49 | ||
| 14 | 50 | ||
| 15 | public FileUploader(String uri) | 51 | public FileUploader(String uri) |
| 16 | { | 52 | { |
| 17 | this.uri = uri; | 53 | this.uri = uri; |
| 54 | + System.Console.WriteLine("Using upload URL: " + uri); | ||
| 18 | this.boundary = "----" + DateTime.Now.Ticks.ToString("x"); | 55 | this.boundary = "----" + DateTime.Now.Ticks.ToString("x"); |
| 19 | } | 56 | } |
| 57 | + | ||
| 58 | + public FileUploader() : this(Environment.GetEnvironmentVariable("KT_ROOT_URL") + "/ktwebservice/upload.php") | ||
| 59 | + { | ||
| 60 | + } | ||
| 61 | + | ||
| 20 | 62 | ||
| 21 | public String getFilename() | 63 | public String getFilename() |
| 22 | { | 64 | { |
| @@ -125,6 +167,8 @@ namespace MonoTests.KnowledgeTree | @@ -125,6 +167,8 @@ namespace MonoTests.KnowledgeTree | ||
| 125 | } | 167 | } |
| 126 | 168 | ||
| 127 | } | 169 | } |
| 170 | + | ||
| 171 | + | ||
| 128 | 172 | ||
| 129 | public class Document | 173 | public class Document |
| 130 | { | 174 | { |
ktwebservice/nunit/makefile
| 1 | -RESULTS=authentication.result document_detail.result document_links.result document_owner.result document_type.result document_history.result document_rename.result document_workflow.result document_metadata.result folder.result document_add.result document_system_metadata.result document_checkout.result | 1 | +RESULTS= authentication.result document_detail.result document_add.result document_checkout.result document_type.result document_links.result document_owner.result document_rename.result document_history.result document_workflow.result document_copy.result folder.result document_metadata.result document_system_metadata.result |
| 2 | #document_download.result | 2 | #document_download.result |
| 3 | PROXY=KTproxy.cs | 3 | PROXY=KTproxy.cs |
| 4 | WSDL=ktdms.wsdl | 4 | WSDL=ktdms.wsdl |
| 5 | -WSDL_URL=http://ktdms.trunk/ktwebservice/index.php?wsdl | 5 | +ROOT_URL=http://ktdms.trunk |
| 6 | +WSDL_URL=${ROOT_URL}/ktwebservice/index.php?wsdl | ||
| 6 | 7 | ||
| 7 | all: ${RESULTS} | 8 | all: ${RESULTS} |
| 8 | 9 | ||
| @@ -11,6 +12,8 @@ results: clean-results ${RESULTS} | @@ -11,6 +12,8 @@ results: clean-results ${RESULTS} | ||
| 11 | KTproxy.dll: KTproxy.cs helper.cs | 12 | KTproxy.dll: KTproxy.cs helper.cs |
| 12 | mcs -r:System.Web.Services /target:library KTproxy.cs helper.cs | 13 | mcs -r:System.Web.Services /target:library KTproxy.cs helper.cs |
| 13 | 14 | ||
| 15 | + | ||
| 16 | + | ||
| 14 | KTproxy.cs: ktdms.wsdl | 17 | KTproxy.cs: ktdms.wsdl |
| 15 | wsdl -out:${PROXY} ${WSDL} | 18 | wsdl -out:${PROXY} ${WSDL} |
| 16 | 19 | ||
| @@ -23,9 +26,9 @@ clean: | @@ -23,9 +26,9 @@ clean: | ||
| 23 | clean-results: | 26 | clean-results: |
| 24 | rm -f ${RESULTS} | 27 | rm -f ${RESULTS} |
| 25 | 28 | ||
| 26 | -%.dll: %.cs KTproxy.dll | ||
| 27 | - mcs -r:System.Web.Services -r:nunit.framework /r:KTproxy.dll -debug /target:library -out:$@ $< | 29 | +%.dll: %.cs KTproxy.dll |
| 30 | + mcs -r:System.Web.Services -r:nunit.framework /r:KTproxy.dll -debug /target:library -out:$@ $< | ||
| 28 | 31 | ||
| 29 | %.result: %.dll | 32 | %.result: %.dll |
| 30 | - nunit-console $< | 33 | + (export KT_ROOT_URL=${ROOT_URL}; nunit-console $<) |
| 31 | mv TestResult.xml $@ | 34 | mv TestResult.xml $@ |
ktwebservice/nunit/query.cs
| @@ -5,25 +5,18 @@ using System.IO; | @@ -5,25 +5,18 @@ using System.IO; | ||
| 5 | namespace MonoTests.KnowledgeTree | 5 | namespace MonoTests.KnowledgeTree |
| 6 | { | 6 | { |
| 7 | [TestFixture] | 7 | [TestFixture] |
| 8 | - public class QueryTest | 8 | + public class QueryTest : KTTest |
| 9 | { | 9 | { |
| 10 | - | ||
| 11 | - private String _session; | ||
| 12 | - private KnowledgeTreeService _kt; | 10 | + |
| 13 | 11 | ||
| 14 | [SetUp] | 12 | [SetUp] |
| 15 | public void SetUp() | 13 | public void SetUp() |
| 16 | - { | ||
| 17 | - this._kt = new KnowledgeTreeService(); | ||
| 18 | - kt_response response = this._kt.login("admin","admin","127.0.0.1"); | ||
| 19 | - this._session = response.message; | ||
| 20 | - | 14 | + { |
| 21 | } | 15 | } |
| 22 | 16 | ||
| 23 | [TearDown] | 17 | [TearDown] |
| 24 | public void TearDown() | 18 | public void TearDown() |
| 25 | - { | ||
| 26 | - this._kt.logout(this._session); | 19 | + { |
| 27 | } | 20 | } |
| 28 | 21 | ||
| 29 | [Test] | 22 | [Test] |
ktwebservice/proxy/proxy.php deleted
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -/** | ||
| 4 | - * $Id:$ | ||
| 5 | - * | ||
| 6 | - * KnowledgeTree Open Source Edition | ||
| 7 | - * Document Management Made Simple | ||
| 8 | - * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited | ||
| 9 | - * | ||
| 10 | - * This program is free software; you can redistribute it and/or modify it under | ||
| 11 | - * the terms of the GNU General Public License version 3 as published by the | ||
| 12 | - * Free Software Foundation. | ||
| 13 | - * | ||
| 14 | - * This program is distributed in the hope that it will be useful, but WITHOUT | ||
| 15 | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| 16 | - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
| 17 | - * details. | ||
| 18 | - * | ||
| 19 | - * You should have received a copy of the GNU General Public License | ||
| 20 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 21 | - * | ||
| 22 | - * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, | ||
| 23 | - * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. | ||
| 24 | - * | ||
| 25 | - * The interactive user interfaces in modified source and object code versions | ||
| 26 | - * of this program must display Appropriate Legal Notices, as required under | ||
| 27 | - * Section 5 of the GNU General Public License version 3. | ||
| 28 | - * | ||
| 29 | - * In accordance with Section 7(b) of the GNU General Public License version 3, | ||
| 30 | - * these Appropriate Legal Notices must retain the display of the "Powered by | ||
| 31 | - * KnowledgeTree" logo and retain the original copyright notice. If the display of the | ||
| 32 | - * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | ||
| 33 | - * must display the words "Powered by KnowledgeTree" and retain the original | ||
| 34 | - * copyright notice. | ||
| 35 | - * Contributor( s): ______________________________________ | ||
| 36 | - * | ||
| 37 | - */ | ||
| 38 | - | ||
| 39 | -set_time_limit(0); | ||
| 40 | - | ||
| 41 | -if ($argc < 3) | ||
| 42 | -{ | ||
| 43 | - die('Usage: proxy.php listenport connectaddr connectport'); | ||
| 44 | -} | ||
| 45 | - | ||
| 46 | -$cport = $argv[1]; | ||
| 47 | -$saddress = $argv[2]; | ||
| 48 | -$sport = $argv[2]; | ||
| 49 | - | ||
| 50 | - | ||
| 51 | -print "Listening on port: $cport\n"; | ||
| 52 | -print "Connecting to: $saddress:$sport\n"; | ||
| 53 | - | ||
| 54 | -if (($lsock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) === false) | ||
| 55 | -{ | ||
| 56 | - die('Cannot create socket: '. socket_strerror($res)); | ||
| 57 | -} | ||
| 58 | - | ||
| 59 | -if (($res = @socket_bind($lsock, '127.0.0.2', $cport)) === false) | ||
| 60 | -{ | ||
| 61 | - die('Cannot bind socket: ' . socket_strerror($res)); | ||
| 62 | -} | ||
| 63 | - | ||
| 64 | -if (($res = socket_listen($lsock, 5)) === false) | ||
| 65 | -{ | ||
| 66 | - die('Cannot listen on socket: ' . socket_strerror($res)); | ||
| 67 | -} | ||
| 68 | - | ||
| 69 | -while(true) | ||
| 70 | -{ | ||
| 71 | - if (($csock = socket_accept($lsock)) < 0) | ||
| 72 | - { | ||
| 73 | - print 'Cannot accept socket: ' . socket_strerror($csock) . "\n"; | ||
| 74 | - continue; | ||
| 75 | - } | ||
| 76 | - print "accepting client\n"; | ||
| 77 | - | ||
| 78 | - if (($ssock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) < 0) | ||
| 79 | - { | ||
| 80 | - print('Cannot create socket: '. socket_strerror($res)); | ||
| 81 | - continue; | ||
| 82 | - } | ||
| 83 | - | ||
| 84 | - print "connecting\n"; | ||
| 85 | - if (($res = socket_connect($ssock, $saddress, $sport)) < 0) | ||
| 86 | - { | ||
| 87 | - print('Cannot bind socket: ' . socket_strerror($res)); | ||
| 88 | - continue; | ||
| 89 | - } | ||
| 90 | - | ||
| 91 | - | ||
| 92 | - ob_implicit_flush(); | ||
| 93 | - | ||
| 94 | - $clientClose = false; | ||
| 95 | - $serverClose = false; | ||
| 96 | - while(!$clientClose && !$serverClose) | ||
| 97 | - { | ||
| 98 | - $arr = array(); | ||
| 99 | - $carr = array(); | ||
| 100 | - $sarr = array(); | ||
| 101 | - | ||
| 102 | - if (!$clientClose) | ||
| 103 | - { | ||
| 104 | - $arr[]= $csock; | ||
| 105 | - $carr[]= $csock; | ||
| 106 | - } | ||
| 107 | - if (!$serverClose) | ||
| 108 | - { | ||
| 109 | - $arr[]= $ssock; | ||
| 110 | - $sarr[]= $ssock; | ||
| 111 | - } | ||
| 112 | -ob_implicit_flush(); $res = socket_select($arr, $e2=null, $e = null, 5); | ||
| 113 | - if ($res === false) | ||
| 114 | - { | ||
| 115 | - print "problem\n"; | ||
| 116 | - break; | ||
| 117 | - } | ||
| 118 | - else | ||
| 119 | - { | ||
| 120 | - $res = @socket_select($carr, $w = NULL, $e = NULL, 0); | ||
| 121 | - if (!$clientClose && ($res === 1)) | ||
| 122 | - { | ||
| 123 | - $buf = @socket_read($csock, 2048, PHP_NORMAL_READ); | ||
| 124 | - if (strlen($buf) != 0) | ||
| 125 | - { | ||
| 126 | - socket_write($ssock, $buf, strlen($buf)); | ||
| 127 | - print "C>>S: $buf\n"; | ||
| 128 | - } | ||
| 129 | - if ($buf === false) | ||
| 130 | - { | ||
| 131 | - $clientClose = true; | ||
| 132 | - socket_write($ssock, "\n", 1); | ||
| 133 | - print "close connection to client\n"; | ||
| 134 | - } | ||
| 135 | - | ||
| 136 | - } | ||
| 137 | - $res = @socket_select($sarr, $w = NULL, $e = NULL, 0); | ||
| 138 | - if (!$serverClose && ($res === 1)) | ||
| 139 | - { | ||
| 140 | - $buf = @socket_read($ssock, 2048, PHP_NORMAL_READ); | ||
| 141 | - if (strlen($buf) != 0) | ||
| 142 | - { | ||
| 143 | - socket_write($csock, $buf, strlen($buf)); | ||
| 144 | - print "C<<S: $buf\n"; | ||
| 145 | - | ||
| 146 | - } | ||
| 147 | - if($buf ===0 ) | ||
| 148 | - { | ||
| 149 | - print "\n"; | ||
| 150 | - } | ||
| 151 | - if ($buf === false) | ||
| 152 | - { | ||
| 153 | - //socket_close($csock); | ||
| 154 | - $serverClose = true; | ||
| 155 | - print "close connection to server\n"; | ||
| 156 | - } | ||
| 157 | - } | ||
| 158 | - } | ||
| 159 | - } | ||
| 160 | - socket_close($ssock); | ||
| 161 | - socket_close($csock); | ||
| 162 | -} | ||
| 163 | - | ||
| 164 | -socket_close($lsock); | ||
| 165 | -?> | ||
| 166 | \ No newline at end of file | 0 | \ No newline at end of file |
ktwebservice/webservice.php
| 1 | <?php | 1 | <?php |
| 2 | - | 2 | +//debugger_start_debug(); |
| 3 | /** | 3 | /** |
| 4 | * | 4 | * |
| 5 | * $Id$ | 5 | * $Id$ |
| @@ -9,36 +9,35 @@ | @@ -9,36 +9,35 @@ | ||
| 9 | * KnowledgeTree Open Source Edition | 9 | * KnowledgeTree Open Source Edition |
| 10 | * Document Management Made Simple | 10 | * Document Management Made Simple |
| 11 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited | 11 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited |
| 12 | - * | 12 | + * |
| 13 | * This program is free software; you can redistribute it and/or modify it under | 13 | * This program is free software; you can redistribute it and/or modify it under |
| 14 | * the terms of the GNU General Public License version 3 as published by the | 14 | * the terms of the GNU General Public License version 3 as published by the |
| 15 | * Free Software Foundation. | 15 | * Free Software Foundation. |
| 16 | - * | 16 | + * |
| 17 | * This program is distributed in the hope that it will be useful, but WITHOUT | 17 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 18 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 18 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 19 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | 19 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 20 | * details. | 20 | * details. |
| 21 | - * | 21 | + * |
| 22 | * You should have received a copy of the GNU General Public License | 22 | * You should have received a copy of the GNU General Public License |
| 23 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 23 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 24 | - * | 24 | + * |
| 25 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, | 25 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, |
| 26 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. | 26 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. |
| 27 | - * | 27 | + * |
| 28 | * The interactive user interfaces in modified source and object code versions | 28 | * The interactive user interfaces in modified source and object code versions |
| 29 | * of this program must display Appropriate Legal Notices, as required under | 29 | * of this program must display Appropriate Legal Notices, as required under |
| 30 | * Section 5 of the GNU General Public License version 3. | 30 | * Section 5 of the GNU General Public License version 3. |
| 31 | - * | 31 | + * |
| 32 | * In accordance with Section 7(b) of the GNU General Public License version 3, | 32 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 33 | * these Appropriate Legal Notices must retain the display of the "Powered by | 33 | * these Appropriate Legal Notices must retain the display of the "Powered by |
| 34 | - * KnowledgeTree" logo and retain the original copyright notice. If the display of the | 34 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the |
| 35 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | 35 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices |
| 36 | - * must display the words "Powered by KnowledgeTree" and retain the original | ||
| 37 | - * copyright notice. | 36 | + * must display the words "Powered by KnowledgeTree" and retain the original |
| 37 | + * copyright notice. | ||
| 38 | * Contributor( s): ______________________________________ | 38 | * Contributor( s): ______________________________________ |
| 39 | * | 39 | * |
| 40 | */ | 40 | */ |
| 41 | - | ||
| 42 | require_once('../config/dmsDefaults.php'); | 41 | require_once('../config/dmsDefaults.php'); |
| 43 | require_once('../ktapi/ktapi.inc.php'); | 42 | require_once('../ktapi/ktapi.inc.php'); |
| 44 | require_once('SOAP/Server.php'); | 43 | require_once('SOAP/Server.php'); |
| @@ -46,7 +45,19 @@ require_once('SOAP/Disco.php'); | @@ -46,7 +45,19 @@ require_once('SOAP/Disco.php'); | ||
| 46 | require_once('KTDownloadManager.inc.php'); | 45 | require_once('KTDownloadManager.inc.php'); |
| 47 | require_once('KTUploadManager.inc.php'); | 46 | require_once('KTUploadManager.inc.php'); |
| 48 | require_once(KT_LIB_DIR . '/storage/storagemanager.inc.php'); | 47 | require_once(KT_LIB_DIR . '/storage/storagemanager.inc.php'); |
| 49 | -require_once(KT_DIR . '/search2/search/search.inc.php'); | 48 | + |
| 49 | +list($major, $minor, $fix) = explode('.', $default->systemVersion); | ||
| 50 | + | ||
| 51 | +if ($major == 3 && $minor >= 5) | ||
| 52 | +{ | ||
| 53 | + define('HAS_SEARCH_FUNCTIONALITY',1); | ||
| 54 | +} | ||
| 55 | +unset($major); unset($minor); unset($fix); | ||
| 56 | + | ||
| 57 | +if (defined('HAS_SEARCH_FUNCTIONALITY')) | ||
| 58 | +{ | ||
| 59 | + require_once(KT_DIR . '/search2/search/search.inc.php'); | ||
| 60 | +} | ||
| 50 | 61 | ||
| 51 | // TODO: Test getting files/metadata based on versioning works and implementation is consistent. | 62 | // TODO: Test getting files/metadata based on versioning works and implementation is consistent. |
| 52 | 63 | ||
| @@ -106,6 +117,8 @@ class KTWebService | @@ -106,6 +117,8 @@ class KTWebService | ||
| 106 | var $namespace; | 117 | var $namespace; |
| 107 | 118 | ||
| 108 | var $mustDebug; | 119 | var $mustDebug; |
| 120 | + var $version; | ||
| 121 | + var $ktapi; | ||
| 109 | 122 | ||
| 110 | 123 | ||
| 111 | 124 | ||
| @@ -114,13 +127,9 @@ class KTWebService | @@ -114,13 +127,9 @@ class KTWebService | ||
| 114 | // Caching was giving some problems, so disable it. | 127 | // Caching was giving some problems, so disable it. |
| 115 | 128 | ||
| 116 | $config = &KTConfig::getSingleton(); | 129 | $config = &KTConfig::getSingleton(); |
| 130 | + $this->version = $config->get('webservice/version', 2); | ||
| 117 | $this->mustDebug = $config->get('webservice/debug', false); | 131 | $this->mustDebug = $config->get('webservice/debug', false); |
| 118 | - $cache_enabled = $config->get('cache/cacheEnabled'); | ||
| 119 | - if ($cache_enabled) | ||
| 120 | - { | ||
| 121 | - $this->error('Cache is enabled. This is likely to cause problems!', 'constructor'); | ||
| 122 | - } | ||
| 123 | - $config->setns('cache','cacheEnabled',false); | 132 | + $this->ktapi = null; |
| 124 | 133 | ||
| 125 | $this->namespace = 'KnowledgeTree'; | 134 | $this->namespace = 'KnowledgeTree'; |
| 126 | 135 | ||
| @@ -140,6 +149,11 @@ class KTWebService | @@ -140,6 +149,11 @@ class KTWebService | ||
| 140 | 'full_path' => 'string', | 149 | 'full_path' => 'string', |
| 141 | ); | 150 | ); |
| 142 | 151 | ||
| 152 | + if ($this->version >= 2) | ||
| 153 | + { | ||
| 154 | + $this->__typedef["{urn:$this->namespace}kt_folder_detail"]['created_by'] = 'string'; | ||
| 155 | + } | ||
| 156 | + | ||
| 143 | $this->__typedef["{urn:$this->namespace}kt_folder_item"] = | 157 | $this->__typedef["{urn:$this->namespace}kt_folder_item"] = |
| 144 | array( | 158 | array( |
| 145 | 'id' => 'int', | 159 | 'id' => 'int', |
| @@ -196,10 +210,43 @@ class KTWebService | @@ -196,10 +210,43 @@ class KTWebService | ||
| 196 | 'workflow_state' => 'string', | 210 | 'workflow_state' => 'string', |
| 197 | 'checkout_by' => 'string', | 211 | 'checkout_by' => 'string', |
| 198 | 'full_path' => 'string', | 212 | 'full_path' => 'string', |
| 199 | - // 'metadata' => "{urn:$this->namespace}kt_metadata_fieldsets", | ||
| 200 | - // 'owner' => 'string', | ||
| 201 | ); | 213 | ); |
| 202 | 214 | ||
| 215 | + if ($this->version >= 2) | ||
| 216 | + { | ||
| 217 | + $this->__typedef["{urn:$this->namespace}kt_document_detail"] = | ||
| 218 | + array( | ||
| 219 | + 'status_code'=>'int', | ||
| 220 | + 'message'=>'string', | ||
| 221 | + 'title' => 'string', | ||
| 222 | + 'document_type' => 'string', | ||
| 223 | + 'version' => 'string', | ||
| 224 | + 'filename' => 'string', | ||
| 225 | + 'created_date' => 'string', | ||
| 226 | + 'created_by' => 'string', | ||
| 227 | + 'modified_date' => 'string', | ||
| 228 | + 'modified_by' => 'string', | ||
| 229 | + 'document_id' => 'int', | ||
| 230 | + 'folder_id' => 'int', | ||
| 231 | + 'workflow' => 'string', | ||
| 232 | + 'workflow_state' => 'string', | ||
| 233 | + //'checkout_by' => 'string', | ||
| 234 | + 'full_path' => 'string', | ||
| 235 | + 'owner'=>'string', | ||
| 236 | + 'is_immutable'=>'boolean', | ||
| 237 | + 'checked_out_date'=>'string', | ||
| 238 | + 'checked_out_by'=>'string', | ||
| 239 | + 'metadata' => "{urn:$this->namespace}kt_metadata_fieldsets", | ||
| 240 | + 'links' => "{urn:$this->namespace}kt_linked_documents", | ||
| 241 | + 'transitions' => "{urn:$this->namespace}kt_workflow_transitions", | ||
| 242 | + 'version_history' => "{urn:$this->namespace}kt_document_version_history", | ||
| 243 | + 'transaction_history' => "{urn:$this->namespace}kt_document_transaction_history", | ||
| 244 | + ); | ||
| 245 | + } | ||
| 246 | + | ||
| 247 | + if (defined('HAS_SEARCH_FUNCTIONALITY')) | ||
| 248 | + { | ||
| 249 | + | ||
| 203 | $this->__typedef["{urn:$this->namespace}kt_search_result_item"] = | 250 | $this->__typedef["{urn:$this->namespace}kt_search_result_item"] = |
| 204 | array( | 251 | array( |
| 205 | 'document_id' => 'int', | 252 | 'document_id' => 'int', |
| @@ -221,7 +268,7 @@ class KTWebService | @@ -221,7 +268,7 @@ class KTWebService | ||
| 221 | 'modified_date' => 'string', | 268 | 'modified_date' => 'string', |
| 222 | 'checked_out_by' => 'string', | 269 | 'checked_out_by' => 'string', |
| 223 | 'checked_out_date' => 'string', | 270 | 'checked_out_date' => 'string', |
| 224 | - 'is_immutable' => 'bool', | 271 | + 'is_immutable' => 'boolean', |
| 225 | 'status' => 'string', | 272 | 'status' => 'string', |
| 226 | ); | 273 | ); |
| 227 | 274 | ||
| @@ -238,6 +285,24 @@ class KTWebService | @@ -238,6 +285,24 @@ class KTWebService | ||
| 238 | 'message' => 'string', | 285 | 'message' => 'string', |
| 239 | 'hits' => "{urn:$this->namespace}kt_search_results" , | 286 | 'hits' => "{urn:$this->namespace}kt_search_results" , |
| 240 | ); | 287 | ); |
| 288 | + } | ||
| 289 | + | ||
| 290 | + if ($this->version >= 2) | ||
| 291 | + { | ||
| 292 | + | ||
| 293 | + $this->__typedef["{urn:$this->namespace}kt_sysdata_item"] = | ||
| 294 | + array( | ||
| 295 | + 'name' => 'string', | ||
| 296 | + 'value' => 'string' | ||
| 297 | + ); | ||
| 298 | + | ||
| 299 | + $this->__typedef["{urn:$this->namespace}kt_sysdata"] = | ||
| 300 | + array( | ||
| 301 | + array( | ||
| 302 | + 'item' => "{urn:$this->namespace}kt_sysdata_item" | ||
| 303 | + ) | ||
| 304 | + ); | ||
| 305 | + } | ||
| 241 | 306 | ||
| 242 | $this->__typedef["{urn:$this->namespace}kt_metadata_selection_item"] = | 307 | $this->__typedef["{urn:$this->namespace}kt_metadata_selection_item"] = |
| 243 | array( | 308 | array( |
| @@ -314,8 +379,7 @@ class KTWebService | @@ -314,8 +379,7 @@ class KTWebService | ||
| 314 | 'username'=>'string', | 379 | 'username'=>'string', |
| 315 | 'version' => 'string', | 380 | 'version' => 'string', |
| 316 | 'comment' => 'string', | 381 | 'comment' => 'string', |
| 317 | - 'datetime' => 'string', | ||
| 318 | - | 382 | + 'datetime' => 'string' |
| 319 | ); | 383 | ); |
| 320 | 384 | ||
| 321 | $this->__typedef["{urn:$this->namespace}kt_linked_document"] = | 385 | $this->__typedef["{urn:$this->namespace}kt_linked_document"] = |
| @@ -325,8 +389,7 @@ class KTWebService | @@ -325,8 +389,7 @@ class KTWebService | ||
| 325 | 'size' => 'int', | 389 | 'size' => 'int', |
| 326 | 'workflow' => 'string', | 390 | 'workflow' => 'string', |
| 327 | 'workflow_state' => 'string', | 391 | 'workflow_state' => 'string', |
| 328 | - 'link_type' => 'string', | ||
| 329 | - | 392 | + 'link_type' => 'string' |
| 330 | ); | 393 | ); |
| 331 | 394 | ||
| 332 | $this->__typedef["{urn:$this->namespace}kt_linked_documents"] = | 395 | $this->__typedef["{urn:$this->namespace}kt_linked_documents"] = |
| @@ -340,7 +403,7 @@ class KTWebService | @@ -340,7 +403,7 @@ class KTWebService | ||
| 340 | array( | 403 | array( |
| 341 | 'status_code'=>'int', | 404 | 'status_code'=>'int', |
| 342 | 'message'=>'string', | 405 | 'message'=>'string', |
| 343 | - 'parent_document_id' => 'string', | 406 | + 'parent_document_id' => 'int', |
| 344 | 'links' => "{urn:$this->namespace}kt_linked_documents" | 407 | 'links' => "{urn:$this->namespace}kt_linked_documents" |
| 345 | ); | 408 | ); |
| 346 | 409 | ||
| @@ -416,11 +479,14 @@ class KTWebService | @@ -416,11 +479,14 @@ class KTWebService | ||
| 416 | ); | 479 | ); |
| 417 | 480 | ||
| 418 | /* methods */ | 481 | /* methods */ |
| 482 | + if (defined('HAS_SEARCH_FUNCTIONALITY')) | ||
| 483 | + { | ||
| 419 | 484 | ||
| 420 | - $this->__dispatch_map['search'] = | ||
| 421 | - array('in' => array('session_id' => 'string', 'search'=>'string' ,'options'=>'string'), | ||
| 422 | - 'out' => array('return' => "{urn:$this->namespace}kt_search_response" ), | ||
| 423 | - ); | 485 | + $this->__dispatch_map['search'] = array( |
| 486 | + 'in' => array('session_id' => 'string', 'search'=>'string' ,'options'=>'string'), | ||
| 487 | + 'out' => array('return' => "{urn:$this->namespace}kt_search_response" ), | ||
| 488 | + ); | ||
| 489 | + } | ||
| 424 | 490 | ||
| 425 | // login | 491 | // login |
| 426 | $this->__dispatch_map['login'] = | 492 | $this->__dispatch_map['login'] = |
| @@ -465,6 +531,17 @@ class KTWebService | @@ -465,6 +531,17 @@ class KTWebService | ||
| 465 | 'out' => array('return' => "{urn:$this->namespace}kt_folder_detail"), | 531 | 'out' => array('return' => "{urn:$this->namespace}kt_folder_detail"), |
| 466 | ); | 532 | ); |
| 467 | 533 | ||
| 534 | + if ($this->version >=2) | ||
| 535 | + { | ||
| 536 | + // create_folder | ||
| 537 | + $this->__dispatch_map['add_folder'] = | ||
| 538 | + array('in' => array('session_id'=>'string','folder_id'=>'int','folder_name' =>'string'), | ||
| 539 | + 'out' => array('return' => "{urn:$this->namespace}kt_folder_detail"), | ||
| 540 | + 'alias'=>'create_folder' | ||
| 541 | + ); | ||
| 542 | + } | ||
| 543 | + | ||
| 544 | + | ||
| 468 | // delete_folder | 545 | // delete_folder |
| 469 | $this->__dispatch_map['delete_folder'] = | 546 | $this->__dispatch_map['delete_folder'] = |
| 470 | array('in' => array('session_id'=>'string','folder_id'=>'int','reason' =>'string'), | 547 | array('in' => array('session_id'=>'string','folder_id'=>'int','reason' =>'string'), |
| @@ -509,11 +586,17 @@ class KTWebService | @@ -509,11 +586,17 @@ class KTWebService | ||
| 509 | ); | 586 | ); |
| 510 | 587 | ||
| 511 | // get_document_detail | 588 | // get_document_detail |
| 512 | - $this->__dispatch_map['get_document_detail'] = | ||
| 513 | - array('in' => array('session_id' => 'string', 'document_id' => 'int' ), | ||
| 514 | - 'out' => array('return' => "{urn:$this->namespace}kt_document_detail"), | 589 | + $this->__dispatch_map['get_document_detail'] = array( |
| 590 | + 'in' => array('session_id' => 'string', 'document_id' => 'int' ), | ||
| 591 | + 'out' => array('return' => "{urn:$this->namespace}kt_document_detail"), | ||
| 515 | ); | 592 | ); |
| 516 | 593 | ||
| 594 | + if ($this->version >= 2) | ||
| 595 | + { | ||
| 596 | + $this->__dispatch_map['get_document_detail']['in'] = array('session_id' => 'string', 'document_id' => 'int', 'detail'=>'string' ); | ||
| 597 | + } | ||
| 598 | + | ||
| 599 | + | ||
| 517 | // checkin_document | 600 | // checkin_document |
| 518 | $this->__dispatch_map['checkin_document'] = | 601 | $this->__dispatch_map['checkin_document'] = |
| 519 | array('in' => array('session_id'=>'string','document_id'=>'int','filename'=>'string','reason' =>'string','tempfilename' =>'string', 'major_update'=>'boolean' ), | 602 | array('in' => array('session_id'=>'string','document_id'=>'int','filename'=>'string','reason' =>'string','tempfilename' =>'string', 'major_update'=>'boolean' ), |
| @@ -533,6 +616,20 @@ class KTWebService | @@ -533,6 +616,20 @@ class KTWebService | ||
| 533 | 'alias' => 'checkin_small_document' | 616 | 'alias' => 'checkin_small_document' |
| 534 | ); | 617 | ); |
| 535 | 618 | ||
| 619 | + if ($this->version >= 2) | ||
| 620 | + { | ||
| 621 | + $this->__dispatch_map['checkin_base64_document_with_metadata'] = | ||
| 622 | + array('in' => array('session_id'=>'string','document_id'=>'int','filename'=>'string','reason' =>'string','base64' =>'string', 'major_update'=>'boolean', 'metadata'=>"{urn:$this->namespace}kt_metadata_fieldsets",'sysdata'=>"{urn:$this->namespace}kt_sysdata" ), | ||
| 623 | + 'out' => array( 'return' => "{urn:$this->namespace}kt_document_detail" ), | ||
| 624 | + 'alias'=>'checkin_small_document_with_metadata' | ||
| 625 | + ); | ||
| 626 | + $this->__dispatch_map['checkin_document_with_metadata'] = | ||
| 627 | + array('in' => array('session_id'=>'string','document_id'=>'int','filename'=>'string','reason' =>'string','tempfilename' =>'string', 'major_update'=>'boolean', 'metadata'=>"{urn:$this->namespace}kt_metadata_fieldsets",'sysdata'=>"{urn:$this->namespace}kt_sysdata" ), | ||
| 628 | + 'out' => array( 'return' => "{urn:$this->namespace}kt_document_detail" ) | ||
| 629 | + ); | ||
| 630 | + | ||
| 631 | + } | ||
| 632 | + | ||
| 536 | // add_document | 633 | // add_document |
| 537 | $this->__dispatch_map['add_document'] = | 634 | $this->__dispatch_map['add_document'] = |
| 538 | array('in' => array('session_id'=>'string','folder_id'=>'int','title'=>'string','filename'=>'string','documentype' =>'string','tempfilename' =>'string' ), | 635 | array('in' => array('session_id'=>'string','folder_id'=>'int','title'=>'string','filename'=>'string','documentype' =>'string','tempfilename' =>'string' ), |
| @@ -553,6 +650,23 @@ class KTWebService | @@ -553,6 +650,23 @@ class KTWebService | ||
| 553 | 650 | ||
| 554 | ); | 651 | ); |
| 555 | 652 | ||
| 653 | + if ($this->version >= 2) | ||
| 654 | + { | ||
| 655 | + $this->__dispatch_map['add_base64_document_with_metadata'] = | ||
| 656 | + array('in' => array('session_id'=>'string','folder_id'=>'int','title'=>'string','filename'=>'string','documentype' =>'string','base64' =>'string', 'metadata'=>"{urn:$this->namespace}kt_metadata_fieldsets",'sysdata'=>"{urn:$this->namespace}kt_sysdata" ), | ||
| 657 | + 'out' => array( 'return' => "{urn:$this->namespace}kt_document_detail" ), | ||
| 658 | + 'alias'=>'add_small_document_with_metadata' | ||
| 659 | + ); | ||
| 660 | + | ||
| 661 | + $this->__dispatch_map['add_document_with_metadata'] = | ||
| 662 | + array('in' => array('session_id'=>'string','folder_id'=>'int','title'=>'string','filename'=>'string','documentype' =>'string','tempfilename' =>'string', 'metadata'=>"{urn:$this->namespace}kt_metadata_fieldsets",'sysdata'=>"{urn:$this->namespace}kt_sysdata" ), | ||
| 663 | + 'out' => array( 'return' => "{urn:$this->namespace}kt_document_detail" ) | ||
| 664 | + ); | ||
| 665 | + | ||
| 666 | + | ||
| 667 | + } | ||
| 668 | + | ||
| 669 | + | ||
| 556 | 670 | ||
| 557 | // get_document_detail_by_name | 671 | // get_document_detail_by_name |
| 558 | $this->__dispatch_map['get_document_detail_by_name'] = | 672 | $this->__dispatch_map['get_document_detail_by_name'] = |
| @@ -560,18 +674,48 @@ class KTWebService | @@ -560,18 +674,48 @@ class KTWebService | ||
| 560 | 'out' => array('return' => "{urn:$this->namespace}kt_document_detail"), | 674 | 'out' => array('return' => "{urn:$this->namespace}kt_document_detail"), |
| 561 | ); | 675 | ); |
| 562 | 676 | ||
| 677 | + if ($this->version >= 2) | ||
| 678 | + { | ||
| 679 | + $this->__dispatch_map['get_document_detail_by_name']['in'] = array('session_id' => 'string', 'folder_id'=>'int', 'document_name' => 'string', 'what'=>'string', 'detail'=>'string' ); | ||
| 680 | + | ||
| 681 | + $this->__dispatch_map['get_document_detail_by_title'] = array( | ||
| 682 | + 'in' => array('session_id' => 'string', 'folder_id'=>'int', 'title' => 'string', 'detail'=>'string' ), | ||
| 683 | + 'out' => array('return' => "{urn:$this->namespace}kt_document_detail"), | ||
| 684 | + ); | ||
| 685 | + | ||
| 686 | + $this->__dispatch_map['get_document_detail_by_filename'] = array( | ||
| 687 | + 'in' => array('session_id' => 'string', 'folder_id'=>'int', 'filename' => 'string', 'detail'=>'string' ), | ||
| 688 | + 'out' => array('return' => "{urn:$this->namespace}kt_document_detail"), | ||
| 689 | + ); | ||
| 690 | + } | ||
| 691 | + | ||
| 563 | // checkout_document | 692 | // checkout_document |
| 564 | $this->__dispatch_map['checkout_document'] = | 693 | $this->__dispatch_map['checkout_document'] = |
| 565 | array('in' => array('session_id'=>'string','document_id'=>'int','reason' =>'string'), | 694 | array('in' => array('session_id'=>'string','document_id'=>'int','reason' =>'string'), |
| 566 | 'out' => array('return' => "{urn:$this->namespace}kt_response" ), | 695 | 'out' => array('return' => "{urn:$this->namespace}kt_response" ), |
| 567 | ); | 696 | ); |
| 568 | 697 | ||
| 698 | + if ($this->version >= 2) | ||
| 699 | + { | ||
| 700 | + $this->__dispatch_map['checkout_document'] = | ||
| 701 | + array('in' => array('session_id'=>'string','document_id'=>'int','reason' =>'string','download'=>'boolean'), | ||
| 702 | + 'out' => array('return' => "{urn:$this->namespace}kt_document_detail" ), | ||
| 703 | + ); | ||
| 704 | + } | ||
| 705 | + | ||
| 706 | + | ||
| 569 | // checkout_small_document | 707 | // checkout_small_document |
| 570 | $this->__dispatch_map['checkout_small_document'] = | 708 | $this->__dispatch_map['checkout_small_document'] = |
| 571 | array('in' => array('session_id'=>'string','document_id'=>'int','reason' =>'string','download' => 'boolean'), | 709 | array('in' => array('session_id'=>'string','document_id'=>'int','reason' =>'string','download' => 'boolean'), |
| 572 | 'out' => array('return' => "{urn:$this->namespace}kt_response" ), | 710 | 'out' => array('return' => "{urn:$this->namespace}kt_response" ), |
| 573 | ); | 711 | ); |
| 574 | 712 | ||
| 713 | + if ($this->version >= 2) | ||
| 714 | + { | ||
| 715 | + $this->__dispatch_map['checkout_small_document']['out'] = array('return' => "{urn:$this->namespace}kt_document_detail" ); | ||
| 716 | + } | ||
| 717 | + | ||
| 718 | + | ||
| 575 | // checkout_base64_document | 719 | // checkout_base64_document |
| 576 | $this->__dispatch_map['checkout_base64_document'] = | 720 | $this->__dispatch_map['checkout_base64_document'] = |
| 577 | array('in' => array('session_id'=>'string','document_id'=>'int','reason' =>'string','download' => 'boolean'), | 721 | array('in' => array('session_id'=>'string','document_id'=>'int','reason' =>'string','download' => 'boolean'), |
| @@ -579,12 +723,25 @@ class KTWebService | @@ -579,12 +723,25 @@ class KTWebService | ||
| 579 | 'alias' => 'checkout_small_document' | 723 | 'alias' => 'checkout_small_document' |
| 580 | ); | 724 | ); |
| 581 | 725 | ||
| 726 | + if ($this->version >= 2) | ||
| 727 | + { | ||
| 728 | + $this->__dispatch_map['checkout_base64_document']['out'] = array('return' => "{urn:$this->namespace}kt_document_detail" ); | ||
| 729 | + } | ||
| 730 | + | ||
| 731 | + | ||
| 582 | // undo_document_checkout | 732 | // undo_document_checkout |
| 583 | $this->__dispatch_map['undo_document_checkout'] = | 733 | $this->__dispatch_map['undo_document_checkout'] = |
| 584 | array('in' => array('session_id'=>'string','document_id'=>'int','reason' =>'string'), | 734 | array('in' => array('session_id'=>'string','document_id'=>'int','reason' =>'string'), |
| 585 | 'out' => array('return' => "{urn:$this->namespace}kt_response" ), | 735 | 'out' => array('return' => "{urn:$this->namespace}kt_response" ), |
| 586 | ); | 736 | ); |
| 587 | 737 | ||
| 738 | + if ($this->version >= 2) | ||
| 739 | + { | ||
| 740 | + $this->__dispatch_map['undo_document_checkout']['out'] = array('return' => "{urn:$this->namespace}kt_document_detail" ); | ||
| 741 | + } | ||
| 742 | + | ||
| 743 | + | ||
| 744 | + | ||
| 588 | // download_document | 745 | // download_document |
| 589 | $this->__dispatch_map['download_document'] = | 746 | $this->__dispatch_map['download_document'] = |
| 590 | array('in' => array('session_id'=>'string','document_id'=>'int' ), | 747 | array('in' => array('session_id'=>'string','document_id'=>'int' ), |
| @@ -617,28 +774,51 @@ class KTWebService | @@ -617,28 +774,51 @@ class KTWebService | ||
| 617 | 'out' => array( 'return' => "{urn:$this->namespace}kt_response" ), | 774 | 'out' => array( 'return' => "{urn:$this->namespace}kt_response" ), |
| 618 | ); | 775 | ); |
| 619 | 776 | ||
| 777 | + if ($this->version >= 2) | ||
| 778 | + { | ||
| 779 | + $this->__dispatch_map['change_document_owner']['out'] = array( 'return' => "{urn:$this->namespace}kt_document_detail" ); | ||
| 780 | + } | ||
| 781 | + | ||
| 782 | + | ||
| 620 | // copy_document | 783 | // copy_document |
| 621 | $this->__dispatch_map['copy_document'] = | 784 | $this->__dispatch_map['copy_document'] = |
| 622 | array('in' => array('session_id'=>'string','document_id'=>'int','folder_id'=>'int','reason'=>'string','newtitle'=>'string','newfilename'=>'string'), | 785 | array('in' => array('session_id'=>'string','document_id'=>'int','folder_id'=>'int','reason'=>'string','newtitle'=>'string','newfilename'=>'string'), |
| 623 | 'out' => array( 'return' => "{urn:$this->namespace}kt_response" ), | 786 | 'out' => array( 'return' => "{urn:$this->namespace}kt_response" ), |
| 624 | ); | 787 | ); |
| 788 | + if ($this->version >= 2) | ||
| 789 | + { | ||
| 790 | + $this->__dispatch_map['copy_document']['out'] = array( 'return' => "{urn:$this->namespace}kt_document_detail" ); | ||
| 791 | + } | ||
| 625 | 792 | ||
| 626 | // move_document | 793 | // move_document |
| 627 | $this->__dispatch_map['move_document'] = | 794 | $this->__dispatch_map['move_document'] = |
| 628 | array('in' => array('session_id'=>'string','document_id'=>'int','folder_id'=>'int','reason'=>'string','newtitle'=>'string','newfilename'=>'string'), | 795 | array('in' => array('session_id'=>'string','document_id'=>'int','folder_id'=>'int','reason'=>'string','newtitle'=>'string','newfilename'=>'string'), |
| 629 | 'out' => array( 'return' => "{urn:$this->namespace}kt_response" ), | 796 | 'out' => array( 'return' => "{urn:$this->namespace}kt_response" ), |
| 630 | ); | 797 | ); |
| 798 | + if ($this->version >= 2) | ||
| 799 | + { | ||
| 800 | + $this->__dispatch_map['move_document']['out'] = array( 'return' => "{urn:$this->namespace}kt_document_detail" ); | ||
| 801 | + } | ||
| 802 | + | ||
| 631 | // rename_document_title | 803 | // rename_document_title |
| 632 | $this->__dispatch_map['rename_document_title'] = | 804 | $this->__dispatch_map['rename_document_title'] = |
| 633 | array('in' => array('session_id'=>'string','document_id'=>'int', 'newtitle'=>'string' ), | 805 | array('in' => array('session_id'=>'string','document_id'=>'int', 'newtitle'=>'string' ), |
| 634 | 'out' => array( 'return' => "{urn:$this->namespace}kt_response" ), | 806 | 'out' => array( 'return' => "{urn:$this->namespace}kt_response" ), |
| 635 | ); | 807 | ); |
| 636 | - | 808 | + if ($this->version >= 2) |
| 809 | + { | ||
| 810 | + $this->__dispatch_map['rename_document_title']['out'] = array( 'return' => "{urn:$this->namespace}kt_document_detail" ); | ||
| 811 | + } | ||
| 637 | // rename_document_filename | 812 | // rename_document_filename |
| 638 | $this->__dispatch_map['rename_document_filename'] = | 813 | $this->__dispatch_map['rename_document_filename'] = |
| 639 | array('in' => array('session_id'=>'string','document_id'=>'int', 'newfilename'=>'string' ), | 814 | array('in' => array('session_id'=>'string','document_id'=>'int', 'newfilename'=>'string' ), |
| 640 | 'out' => array( 'return' => "{urn:$this->namespace}kt_response" ), | 815 | 'out' => array( 'return' => "{urn:$this->namespace}kt_response" ), |
| 641 | ); | 816 | ); |
| 817 | + if ($this->version >= 2) | ||
| 818 | + { | ||
| 819 | + $this->__dispatch_map['rename_document_filename']['out'] = array( 'return' => "{urn:$this->namespace}kt_document_detail" ); | ||
| 820 | + } | ||
| 821 | + | ||
| 642 | 822 | ||
| 643 | // change_document_type | 823 | // change_document_type |
| 644 | $this->__dispatch_map['change_document_type'] = | 824 | $this->__dispatch_map['change_document_type'] = |
| @@ -646,23 +826,51 @@ class KTWebService | @@ -646,23 +826,51 @@ class KTWebService | ||
| 646 | 'out' => array( 'return' => "{urn:$this->namespace}kt_response" ), | 826 | 'out' => array( 'return' => "{urn:$this->namespace}kt_response" ), |
| 647 | ); | 827 | ); |
| 648 | 828 | ||
| 829 | + if ($this->version >= 2) | ||
| 830 | + { | ||
| 831 | + $this->__dispatch_map['change_document_type']['out'] = array( 'return' => "{urn:$this->namespace}kt_document_detail" ); | ||
| 832 | + } | ||
| 833 | + | ||
| 649 | // start_document_workflow | 834 | // start_document_workflow |
| 650 | $this->__dispatch_map['start_document_workflow'] = | 835 | $this->__dispatch_map['start_document_workflow'] = |
| 651 | array('in' => array('session_id'=>'string','document_id'=>'int', 'workflow'=>'string' ), | 836 | array('in' => array('session_id'=>'string','document_id'=>'int', 'workflow'=>'string' ), |
| 652 | 'out' => array( 'return' => "{urn:$this->namespace}kt_response" ), | 837 | 'out' => array( 'return' => "{urn:$this->namespace}kt_response" ), |
| 653 | ); | 838 | ); |
| 839 | + | ||
| 840 | + if ($this->version >= 2) | ||
| 841 | + { | ||
| 842 | + $this->__dispatch_map['start_document_workflow']['out'] = array( 'return' => "{urn:$this->namespace}kt_document_detail" ); | ||
| 843 | + } | ||
| 844 | + | ||
| 654 | // delete_document_workflow | 845 | // delete_document_workflow |
| 655 | $this->__dispatch_map['delete_document_workflow'] = | 846 | $this->__dispatch_map['delete_document_workflow'] = |
| 656 | array('in' => array('session_id'=>'string','document_id'=>'int' ), | 847 | array('in' => array('session_id'=>'string','document_id'=>'int' ), |
| 657 | - 'out' => array( 'return' => "{urn:$this->namespace}kt_response" ), | 848 | + 'out' => array( 'return' => "{urn:$this->namespace}kt_response" ) |
| 658 | ); | 849 | ); |
| 659 | 850 | ||
| 851 | + if ($this->version >= 2) | ||
| 852 | + { | ||
| 853 | + $this->__dispatch_map['delete_document_workflow']['out'] = array( 'return' => "{urn:$this->namespace}kt_document_detail" ); | ||
| 854 | + | ||
| 855 | + // stop_document_workflow | ||
| 856 | + $this->__dispatch_map['stop_document_workflow'] = | ||
| 857 | + array('in' => array('session_id'=>'string','document_id'=>'int' ), | ||
| 858 | + 'out' => array( 'return' => "{urn:$this->namespace}kt_document_detail" ), | ||
| 859 | + 'alias'=>'delete_document_workflow' | ||
| 860 | + ); | ||
| 861 | + } | ||
| 862 | + | ||
| 660 | // perform_document_workflow_transition | 863 | // perform_document_workflow_transition |
| 661 | $this->__dispatch_map['perform_document_workflow_transition'] = | 864 | $this->__dispatch_map['perform_document_workflow_transition'] = |
| 662 | array('in' => array('session_id'=>'string','document_id'=>'int','transition'=>'string','reason'=>'string' ), | 865 | array('in' => array('session_id'=>'string','document_id'=>'int','transition'=>'string','reason'=>'string' ), |
| 663 | 'out' => array( 'return' => "{urn:$this->namespace}kt_response" ), | 866 | 'out' => array( 'return' => "{urn:$this->namespace}kt_response" ), |
| 664 | ); | 867 | ); |
| 665 | 868 | ||
| 869 | + if ($this->version >= 2) | ||
| 870 | + { | ||
| 871 | + $this->__dispatch_map['perform_document_workflow_transition']['out'] = array( 'return' => "{urn:$this->namespace}kt_document_detail" ); | ||
| 872 | + } | ||
| 873 | + | ||
| 666 | // get_document_metadata | 874 | // get_document_metadata |
| 667 | $this->__dispatch_map['get_document_metadata'] = | 875 | $this->__dispatch_map['get_document_metadata'] = |
| 668 | array('in' => array('session_id'=>'string','document_id'=>'int' ), | 876 | array('in' => array('session_id'=>'string','document_id'=>'int' ), |
| @@ -676,10 +884,20 @@ class KTWebService | @@ -676,10 +884,20 @@ class KTWebService | ||
| 676 | ); | 884 | ); |
| 677 | //update_document_metadata | 885 | //update_document_metadata |
| 678 | $this->__dispatch_map['update_document_metadata'] = | 886 | $this->__dispatch_map['update_document_metadata'] = |
| 679 | - array('in' => array('session_id'=>'string','document_id'=>'int','metadata'=>"{urn:$this->namespace}kt_metadata_fieldsets" ), | 887 | + array('in' => array('session_id'=>'string','document_id'=>'int','metadata'=>"{urn:$this->namespace}kt_metadata_fieldsets" ), |
| 680 | 'out' => array( 'return' => "{urn:$this->namespace}kt_response" ), | 888 | 'out' => array( 'return' => "{urn:$this->namespace}kt_response" ), |
| 681 | ); | 889 | ); |
| 682 | 890 | ||
| 891 | + if ($this->version >= 2) | ||
| 892 | + { | ||
| 893 | + $this->__dispatch_map['update_document_metadata'] = | ||
| 894 | + array('in' => array('session_id'=>'string','document_id'=>'int','metadata'=>"{urn:$this->namespace}kt_metadata_fieldsets", 'sysdata'=>"{urn:$this->namespace}kt_sysdata" ), | ||
| 895 | + 'out' => array( 'return' => "{urn:$this->namespace}kt_document_detail" ) | ||
| 896 | + ); | ||
| 897 | + | ||
| 898 | + | ||
| 899 | + } | ||
| 900 | + | ||
| 683 | 901 | ||
| 684 | //get_document_workflow_transitions | 902 | //get_document_workflow_transitions |
| 685 | $this->__dispatch_map['get_document_workflow_transitions'] = | 903 | $this->__dispatch_map['get_document_workflow_transitions'] = |
| @@ -728,9 +946,10 @@ class KTWebService | @@ -728,9 +946,10 @@ class KTWebService | ||
| 728 | 946 | ||
| 729 | } | 947 | } |
| 730 | 948 | ||
| 731 | - function debug($msg, $function = null) | 949 | + function debug($msg, $function = null, $level=0) |
| 732 | { | 950 | { |
| 733 | - if ($this->mustDebug) | 951 | + if ($this->mustDebug === false) return; |
| 952 | + if ($this->mustDebug >= $level) | ||
| 734 | { | 953 | { |
| 735 | global $default; | 954 | global $default; |
| 736 | if (!is_null($function)) | 955 | if (!is_null($function)) |
| @@ -763,6 +982,11 @@ class KTWebService | @@ -763,6 +982,11 @@ class KTWebService | ||
| 763 | */ | 982 | */ |
| 764 | function &get_ktapi($session_id) | 983 | function &get_ktapi($session_id) |
| 765 | { | 984 | { |
| 985 | + if (!is_null($this->ktapi)) | ||
| 986 | + { | ||
| 987 | + return $this->ktapi; | ||
| 988 | + } | ||
| 989 | + | ||
| 766 | $kt = new KTAPI(); | 990 | $kt = new KTAPI(); |
| 767 | 991 | ||
| 768 | $session = $kt->get_active_session($session_id, null); | 992 | $session = $kt->get_active_session($session_id, null); |
| @@ -776,6 +1000,7 @@ class KTWebService | @@ -776,6 +1000,7 @@ class KTWebService | ||
| 776 | 1000 | ||
| 777 | return $response; | 1001 | return $response; |
| 778 | } | 1002 | } |
| 1003 | + $this->ktapi = $kt; | ||
| 779 | return $kt; | 1004 | return $kt; |
| 780 | } | 1005 | } |
| 781 | 1006 | ||
| @@ -1368,9 +1593,9 @@ class KTWebService | @@ -1368,9 +1593,9 @@ class KTWebService | ||
| 1368 | * @param int $document_id | 1593 | * @param int $document_id |
| 1369 | * @return kt_document_detail. status_code can be KTWS_ERR_INVALID_SESSION, KTWS_ERR_INVALID_DOCUMENT or KTWS_SUCCESS | 1594 | * @return kt_document_detail. status_code can be KTWS_ERR_INVALID_SESSION, KTWS_ERR_INVALID_DOCUMENT or KTWS_SUCCESS |
| 1370 | */ | 1595 | */ |
| 1371 | - function get_document_detail($session_id, $document_id) | 1596 | + function get_document_detail($session_id, $document_id, $detail='') |
| 1372 | { | 1597 | { |
| 1373 | - $this->debug("get_document_detail('$session_id',$document_id)"); | 1598 | + $this->debug("get_document_detail('$session_id',$document_id,'$detail')"); |
| 1374 | $kt = &$this->get_ktapi($session_id ); | 1599 | $kt = &$this->get_ktapi($session_id ); |
| 1375 | if (is_array($kt)) | 1600 | if (is_array($kt)) |
| 1376 | { | 1601 | { |
| @@ -1389,6 +1614,7 @@ class KTWebService | @@ -1389,6 +1614,7 @@ class KTWebService | ||
| 1389 | return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $response); | 1614 | return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $response); |
| 1390 | } | 1615 | } |
| 1391 | 1616 | ||
| 1617 | + $detailstr = $detail; | ||
| 1392 | $detail = $document->get_detail(); | 1618 | $detail = $document->get_detail(); |
| 1393 | if (PEAR::isError($detail)) | 1619 | if (PEAR::isError($detail)) |
| 1394 | { | 1620 | { |
| @@ -1402,9 +1628,62 @@ class KTWebService | @@ -1402,9 +1628,62 @@ class KTWebService | ||
| 1402 | 1628 | ||
| 1403 | $detail['status_code']=KTWS_SUCCESS; | 1629 | $detail['status_code']=KTWS_SUCCESS; |
| 1404 | $detail['message']=''; | 1630 | $detail['message']=''; |
| 1631 | + | ||
| 1632 | + if ($this->version >= 2) | ||
| 1633 | + { | ||
| 1634 | + $detail['metadata'] = array(); | ||
| 1635 | + $detail['links'] = array(); | ||
| 1636 | + $detail['transitions'] = array(); | ||
| 1637 | + $detail['version_history'] = array(); | ||
| 1638 | + $detail['transaction_history'] = array(); | ||
| 1639 | + | ||
| 1640 | + | ||
| 1641 | + if (stripos($detailstr,'M') !== false) | ||
| 1642 | + { | ||
| 1643 | + $response = $this->get_document_metadata($session_id, $document_id); | ||
| 1644 | + $detail['metadata'] = $response->value['metadata']; | ||
| 1645 | + } | ||
| 1646 | + | ||
| 1647 | + if (stripos($detailstr,'L') !== false) | ||
| 1648 | + { | ||
| 1649 | + $response = $this->get_document_metadata($session_id, $document_id); | ||
| 1650 | + $detail['links'] = $response->value['links']; | ||
| 1651 | + } | ||
| 1652 | + | ||
| 1653 | + if (stripos($detailstr,'T') !== false) | ||
| 1654 | + { | ||
| 1655 | + $response = $this->get_document_workflow_transitions($session_id, $document_id); | ||
| 1656 | + $detail['transitions'] = $response->value['transitions']; | ||
| 1657 | + } | ||
| 1658 | + | ||
| 1659 | + if (stripos($detailstr,'V') !== false) | ||
| 1660 | + { | ||
| 1661 | + $response = $this->get_document_version_history($session_id, $document_id); | ||
| 1662 | + $detail['version_history'] = $response->value['history']; | ||
| 1663 | + } | ||
| 1664 | + | ||
| 1665 | + if (stripos($detailstr,'H') !== false) | ||
| 1666 | + { | ||
| 1667 | + $response = $this->get_document_transaction_history($session_id, $document_id); | ||
| 1668 | + $detail['transaction_history'] = $response->value['history']; | ||
| 1669 | + } | ||
| 1670 | + | ||
| 1671 | + } | ||
| 1672 | + | ||
| 1405 | return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $detail); | 1673 | return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $detail); |
| 1406 | } | 1674 | } |
| 1407 | 1675 | ||
| 1676 | + function get_document_detail_by_filename($session_id, $folder_id, $filename, $detail='') | ||
| 1677 | + { | ||
| 1678 | + return $this->get_document_detail_by_name($session_id, $folder_id, $filename, 'F', $detail); | ||
| 1679 | + } | ||
| 1680 | + | ||
| 1681 | + function get_document_detail_by_title($session_id, $folder_id, $title, $detail='') | ||
| 1682 | + { | ||
| 1683 | + return $this->get_document_detail_by_name($session_id, $folder_id, $title, 'T', $detail); | ||
| 1684 | + } | ||
| 1685 | + | ||
| 1686 | + | ||
| 1408 | /** | 1687 | /** |
| 1409 | * Returns document detail given a document name which could include a full path. | 1688 | * Returns document detail given a document name which could include a full path. |
| 1410 | * | 1689 | * |
| @@ -1413,9 +1692,9 @@ class KTWebService | @@ -1413,9 +1692,9 @@ class KTWebService | ||
| 1413 | * @param string @what | 1692 | * @param string @what |
| 1414 | * @return kt_document_detail. status_code can be KTWS_ERR_INVALID_SESSION, KTWS_ERR_INVALID_FOLDER, KTWS_ERR_INVALID_DOCUMENT or KTWS_SUCCESS | 1693 | * @return kt_document_detail. status_code can be KTWS_ERR_INVALID_SESSION, KTWS_ERR_INVALID_FOLDER, KTWS_ERR_INVALID_DOCUMENT or KTWS_SUCCESS |
| 1415 | */ | 1694 | */ |
| 1416 | - function get_document_detail_by_name($session_id, $document_name, $what='T') | 1695 | + function get_document_detail_by_name($session_id, $folder_id, $document_name, $what='T', $detail='') |
| 1417 | { | 1696 | { |
| 1418 | - $this->debug("get_document_detail_by_name('$session_id','$document_name','$what')"); | 1697 | + $this->debug("get_document_detail_by_name('$session_id','$document_name','$what','$detail')"); |
| 1419 | $response=array( | 1698 | $response=array( |
| 1420 | 'status_code'=>KTWS_ERR_INVALID_FOLDER, | 1699 | 'status_code'=>KTWS_ERR_INVALID_FOLDER, |
| 1421 | 'message'=>'' | 1700 | 'message'=>'' |
| @@ -1439,10 +1718,11 @@ class KTWebService | @@ -1439,10 +1718,11 @@ class KTWebService | ||
| 1439 | return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $kt); | 1718 | return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $kt); |
| 1440 | } | 1719 | } |
| 1441 | 1720 | ||
| 1442 | - $root = &$kt->get_root_folder(); | 1721 | + if ($folder_id < 1) $folder_id = 1; |
| 1722 | + $root = &$kt->get_folder_by_id($folder_id); | ||
| 1443 | if (PEAR::isError($root)) | 1723 | if (PEAR::isError($root)) |
| 1444 | { | 1724 | { |
| 1445 | - $this->debug("get_document_detail_by_name - cannot get root folder - " . $root->getMessage(), $session_id); | 1725 | + $this->debug("get_document_detail_by_name - cannot get root folder - folder_id = $folder_id - " . $root->getMessage(), $session_id); |
| 1446 | 1726 | ||
| 1447 | return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $response); | 1727 | return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $response); |
| 1448 | } | 1728 | } |
| @@ -1466,6 +1746,8 @@ class KTWebService | @@ -1466,6 +1746,8 @@ class KTWebService | ||
| 1466 | return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $response); | 1746 | return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $response); |
| 1467 | } | 1747 | } |
| 1468 | 1748 | ||
| 1749 | + $detailstr = $detail; | ||
| 1750 | + | ||
| 1469 | $detail = $document->get_detail(); | 1751 | $detail = $document->get_detail(); |
| 1470 | if (PEAR::isError($detail)) | 1752 | if (PEAR::isError($detail)) |
| 1471 | { | 1753 | { |
| @@ -1480,6 +1762,47 @@ class KTWebService | @@ -1480,6 +1762,47 @@ class KTWebService | ||
| 1480 | $detail['status_code']=KTWS_SUCCESS; | 1762 | $detail['status_code']=KTWS_SUCCESS; |
| 1481 | $detail['message']=''; | 1763 | $detail['message']=''; |
| 1482 | 1764 | ||
| 1765 | + | ||
| 1766 | + if ($this->version >= 2) | ||
| 1767 | + { | ||
| 1768 | + | ||
| 1769 | + $detail['metadata'] = array(); | ||
| 1770 | + $detail['links'] = array(); | ||
| 1771 | + $detail['transitions'] = array(); | ||
| 1772 | + $detail['version_history'] = array(); | ||
| 1773 | + $detail['transaction_history'] = array(); | ||
| 1774 | + | ||
| 1775 | + if (stripos($detailstr,'M') !== false) | ||
| 1776 | + { | ||
| 1777 | + $response = $this->get_document_metadata($session_id, $document_id); | ||
| 1778 | + $detail['metadata'] = $response->value['metadata']; | ||
| 1779 | + } | ||
| 1780 | + | ||
| 1781 | + if (stripos($detailstr,'L') !== false) | ||
| 1782 | + { | ||
| 1783 | + $response = $this->get_document_metadata($session_id, $document_id); | ||
| 1784 | + $detail['links'] = $response->value['links']; | ||
| 1785 | + } | ||
| 1786 | + | ||
| 1787 | + if (stripos($detailstr,'T') !== false) | ||
| 1788 | + { | ||
| 1789 | + $response = $this->get_document_workflow_transitions($session_id, $document_id); | ||
| 1790 | + $detail['transitions'] = $response->value['transitions']; | ||
| 1791 | + } | ||
| 1792 | + | ||
| 1793 | + if (stripos($detailstr,'V') !== false) | ||
| 1794 | + { | ||
| 1795 | + $response = $this->get_document_version_history($session_id, $document_id); | ||
| 1796 | + $detail['version_history'] = $response->value['history']; | ||
| 1797 | + } | ||
| 1798 | + | ||
| 1799 | + if (stripos($detailstr,'H') !== false) | ||
| 1800 | + { | ||
| 1801 | + $response = $this->get_document_transaction_history($session_id, $document_id); | ||
| 1802 | + $detail['transaction_history'] = $response->value['history']; | ||
| 1803 | + } | ||
| 1804 | + } | ||
| 1805 | + | ||
| 1483 | return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $detail); | 1806 | return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $detail); |
| 1484 | } | 1807 | } |
| 1485 | 1808 | ||
| @@ -1552,6 +1875,76 @@ class KTWebService | @@ -1552,6 +1875,76 @@ class KTWebService | ||
| 1552 | return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $detail); | 1875 | return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $detail); |
| 1553 | } | 1876 | } |
| 1554 | 1877 | ||
| 1878 | + function add_small_document_with_metadata($session_id, $folder_id, $title, $filename, $documenttype, $base64, $metadata, $sysdata) | ||
| 1879 | + { | ||
| 1880 | + $add_result = $this->add_small_document($session_id, $folder_id, $title, $filename, $documenttype, $base64); | ||
| 1881 | + | ||
| 1882 | + $status_code = $add_result->value['status_code']; | ||
| 1883 | + if ($status_code != 0) | ||
| 1884 | + { | ||
| 1885 | + return $add_result; | ||
| 1886 | + } | ||
| 1887 | + $document_id = $add_result->value['document_id']; | ||
| 1888 | + | ||
| 1889 | + $update_result = $this->update_document_metadata($session_id, $document_id, $metadata, $sysdata); | ||
| 1890 | + $status_code = $update_result->value['status_code']; | ||
| 1891 | + if ($status_code != 0) | ||
| 1892 | + { | ||
| 1893 | + return $update_result; | ||
| 1894 | + } | ||
| 1895 | + | ||
| 1896 | + $kt = &$this->get_ktapi($session_id ); | ||
| 1897 | + if (is_array($kt)) | ||
| 1898 | + { | ||
| 1899 | + return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $kt); | ||
| 1900 | + } | ||
| 1901 | + | ||
| 1902 | + $document = $kt->get_document_by_id($document_id); | ||
| 1903 | + $result = $document->mergeWithLastMetadataVersion(); | ||
| 1904 | + if (PEAR::isError($result)) | ||
| 1905 | + { | ||
| 1906 | + // not much we can do, maybe just log! | ||
| 1907 | + } | ||
| 1908 | + | ||
| 1909 | + return $update_result; | ||
| 1910 | + } | ||
| 1911 | + | ||
| 1912 | + function add_document_with_metadata($session_id, $folder_id, $title, $filename, $documenttype, $tempfilename, $metadata, $sysdata) | ||
| 1913 | + { | ||
| 1914 | + $add_result = $this->add_document($session_id, $folder_id, $title, $filename, $documenttype, $tempfilename); | ||
| 1915 | + | ||
| 1916 | + $status_code = $add_result->value['status_code']; | ||
| 1917 | + if ($status_code != 0) | ||
| 1918 | + { | ||
| 1919 | + return $add_result; | ||
| 1920 | + } | ||
| 1921 | + $document_id = $add_result->value['document_id']; | ||
| 1922 | + | ||
| 1923 | + $update_result = $this->update_document_metadata($session_id, $document_id, $metadata, $sysdata); | ||
| 1924 | + $status_code = $update_result->value['status_code']; | ||
| 1925 | + if ($status_code != 0) | ||
| 1926 | + { | ||
| 1927 | + return $update_result; | ||
| 1928 | + } | ||
| 1929 | + | ||
| 1930 | + $kt = &$this->get_ktapi($session_id ); | ||
| 1931 | + if (is_array($kt)) | ||
| 1932 | + { | ||
| 1933 | + return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $kt); | ||
| 1934 | + } | ||
| 1935 | + | ||
| 1936 | + $document = $kt->get_document_by_id($document_id); | ||
| 1937 | + $result = $document->mergeWithLastMetadataVersion(); | ||
| 1938 | + if (PEAR::isError($result)) | ||
| 1939 | + { | ||
| 1940 | + // not much we can do, maybe just log! | ||
| 1941 | + } | ||
| 1942 | + | ||
| 1943 | + return $update_result; | ||
| 1944 | + } | ||
| 1945 | + | ||
| 1946 | + | ||
| 1947 | + | ||
| 1555 | /** | 1948 | /** |
| 1556 | * Adds a document to the repository. | 1949 | * Adds a document to the repository. |
| 1557 | * | 1950 | * |
| @@ -1705,11 +2098,78 @@ class KTWebService | @@ -1705,11 +2098,78 @@ class KTWebService | ||
| 1705 | return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $response); | 2098 | return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $response); |
| 1706 | } | 2099 | } |
| 1707 | 2100 | ||
| 1708 | - $response['status_code'] = KTWS_SUCCESS; | ||
| 1709 | - | ||
| 1710 | - return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $response); | 2101 | + // get status after checkin |
| 2102 | + return $this->get_document_detail($session_id, $document_id); | ||
| 1711 | } | 2103 | } |
| 1712 | 2104 | ||
| 2105 | + | ||
| 2106 | + function checkin_small_document_with_metadata($session_id, $document_id, $filename, $reason, $base64, $major_update, $metadata, $sysdata) | ||
| 2107 | + { | ||
| 2108 | + $add_result = $this->checkin_small_document($session_id, $document_id, $filename, $reason, $base64, $major_update); | ||
| 2109 | + | ||
| 2110 | + $status_code = $add_result->value['status_code']; | ||
| 2111 | + if ($status_code != 0) | ||
| 2112 | + { | ||
| 2113 | + return $add_result; | ||
| 2114 | + } | ||
| 2115 | + | ||
| 2116 | + $update_result = $this->update_document_metadata($session_id, $document_id, $metadata, $sysdata); | ||
| 2117 | + $status_code = $update_result->value['status_code']; | ||
| 2118 | + if ($status_code != 0) | ||
| 2119 | + { | ||
| 2120 | + return $update_result; | ||
| 2121 | + } | ||
| 2122 | + | ||
| 2123 | + $kt = &$this->get_ktapi($session_id ); | ||
| 2124 | + if (is_array($kt)) | ||
| 2125 | + { | ||
| 2126 | + return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $kt); | ||
| 2127 | + } | ||
| 2128 | + | ||
| 2129 | + $document = $kt->get_document_by_id($document_id); | ||
| 2130 | + $result = $document->mergeWithLastMetadataVersion(); | ||
| 2131 | + if (PEAR::isError($result)) | ||
| 2132 | + { | ||
| 2133 | + // not much we can do, maybe just log! | ||
| 2134 | + } | ||
| 2135 | + | ||
| 2136 | + return $update_result; | ||
| 2137 | + } | ||
| 2138 | + | ||
| 2139 | + function checkin_document_with_metadata($session_id, $document_id, $filename, $reason, $tempfilename, $major_update, $metadata, $sysdata) | ||
| 2140 | + { | ||
| 2141 | + $add_result = $this->checkin_document($session_id, $document_id, $filename, $reason, $tempfilename, $major_update); | ||
| 2142 | + | ||
| 2143 | + $status_code = $add_result->value['status_code']; | ||
| 2144 | + if ($status_code != 0) | ||
| 2145 | + { | ||
| 2146 | + return $add_result; | ||
| 2147 | + } | ||
| 2148 | + | ||
| 2149 | + $update_result = $this->update_document_metadata($session_id, $document_id, $metadata, $sysdata); | ||
| 2150 | + $status_code = $update_result->value['status_code']; | ||
| 2151 | + if ($status_code != 0) | ||
| 2152 | + { | ||
| 2153 | + return $update_result; | ||
| 2154 | + } | ||
| 2155 | + | ||
| 2156 | + $kt = &$this->get_ktapi($session_id ); | ||
| 2157 | + if (is_array($kt)) | ||
| 2158 | + { | ||
| 2159 | + return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $kt); | ||
| 2160 | + } | ||
| 2161 | + | ||
| 2162 | + $document = $kt->get_document_by_id($document_id); | ||
| 2163 | + $result = $document->mergeWithLastMetadataVersion(); | ||
| 2164 | + if (PEAR::isError($result)) | ||
| 2165 | + { | ||
| 2166 | + // not much we can do, maybe just log! | ||
| 2167 | + } | ||
| 2168 | + | ||
| 2169 | + return $update_result; | ||
| 2170 | + } | ||
| 2171 | + | ||
| 2172 | + | ||
| 1713 | /** | 2173 | /** |
| 1714 | * Does a document checkin. | 2174 | * Does a document checkin. |
| 1715 | * | 2175 | * |
| @@ -1795,10 +2255,8 @@ class KTWebService | @@ -1795,10 +2255,8 @@ class KTWebService | ||
| 1795 | $this->debug("checkin_small_document - cannot checkin document - " . $result->getMessage(), $session_id); | 2255 | $this->debug("checkin_small_document - cannot checkin document - " . $result->getMessage(), $session_id); |
| 1796 | return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $response); | 2256 | return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $response); |
| 1797 | } | 2257 | } |
| 1798 | - | ||
| 1799 | - $response['status_code'] = KTWS_SUCCESS; | ||
| 1800 | - | ||
| 1801 | - return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $response); | 2258 | + // get status after checkin |
| 2259 | + return $this->get_document_detail($session_id, $document_id); | ||
| 1802 | } | 2260 | } |
| 1803 | 2261 | ||
| 1804 | /** | 2262 | /** |
| @@ -1807,9 +2265,9 @@ class KTWebService | @@ -1807,9 +2265,9 @@ class KTWebService | ||
| 1807 | * @param string $session_id | 2265 | * @param string $session_id |
| 1808 | * @param int $document_id | 2266 | * @param int $document_id |
| 1809 | * @param string $reason | 2267 | * @param string $reason |
| 1810 | - * @return kt_response. status_code can be KTWS_ERR_INVALID_SESSION, KTWS_ERR_INVALID_FOLDER or KTWS_SUCCESS | 2268 | + * @return kt_document_detail. status_code can be KTWS_ERR_INVALID_SESSION, KTWS_ERR_INVALID_FOLDER or KTWS_SUCCESS |
| 1811 | */ | 2269 | */ |
| 1812 | - function checkout_document($session_id, $document_id, $reason) | 2270 | + function checkout_document($session_id, $document_id, $reason,$download=true) |
| 1813 | { | 2271 | { |
| 1814 | $this->debug("checkout_document('$session_id',$document_id,'$reason')"); | 2272 | $this->debug("checkout_document('$session_id',$document_id,'$reason')"); |
| 1815 | 2273 | ||
| @@ -1842,14 +2300,26 @@ class KTWebService | @@ -1842,14 +2300,26 @@ class KTWebService | ||
| 1842 | 2300 | ||
| 1843 | $session = &$kt->get_session(); | 2301 | $session = &$kt->get_session(); |
| 1844 | 2302 | ||
| 1845 | - $download_manager = new KTDownloadManager(); | ||
| 1846 | - $download_manager->set_session($session->session); | ||
| 1847 | - $download_manager->cleanup(); | ||
| 1848 | - $url = $download_manager->allow_download($document); | 2303 | + $url = ''; |
| 2304 | + if ($download) | ||
| 2305 | + { | ||
| 2306 | + $download_manager = new KTDownloadManager(); | ||
| 2307 | + $download_manager->set_session($session->session); | ||
| 2308 | + $download_manager->cleanup(); | ||
| 2309 | + $url = $download_manager->allow_download($document); | ||
| 2310 | + } | ||
| 1849 | 2311 | ||
| 1850 | $response['status_code'] = KTWS_SUCCESS; | 2312 | $response['status_code'] = KTWS_SUCCESS; |
| 1851 | $response['message'] = $url; | 2313 | $response['message'] = $url; |
| 1852 | 2314 | ||
| 2315 | + if ($this->version >= 2) | ||
| 2316 | + { | ||
| 2317 | + $result = $this->get_document_detail($session_id, $document_id); | ||
| 2318 | + $result->value['message'] = $url; | ||
| 2319 | + | ||
| 2320 | + return $result; | ||
| 2321 | + } | ||
| 2322 | + | ||
| 1853 | return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response); | 2323 | return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response); |
| 1854 | } | 2324 | } |
| 1855 | 2325 | ||
| @@ -1860,7 +2330,7 @@ class KTWebService | @@ -1860,7 +2330,7 @@ class KTWebService | ||
| 1860 | * @param int $document_id | 2330 | * @param int $document_id |
| 1861 | * @param string $reason | 2331 | * @param string $reason |
| 1862 | * @param boolean $download | 2332 | * @param boolean $download |
| 1863 | - * @return kt_response status_code can be KTWS_ERR_INVALID_SESSION, KTWS_ERR_INVALID_FOLDER or KTWS_SUCCESS | 2333 | + * @return kt_document_detail status_code can be KTWS_ERR_INVALID_SESSION, KTWS_ERR_INVALID_FOLDER or KTWS_SUCCESS |
| 1864 | */ | 2334 | */ |
| 1865 | function checkout_small_document($session_id, $document_id, $reason, $download) | 2335 | function checkout_small_document($session_id, $document_id, $reason, $download) |
| 1866 | { | 2336 | { |
| @@ -1916,6 +2386,15 @@ class KTWebService | @@ -1916,6 +2386,15 @@ class KTWebService | ||
| 1916 | $response['status_code'] = KTWS_SUCCESS; | 2386 | $response['status_code'] = KTWS_SUCCESS; |
| 1917 | $response['message'] = $content; | 2387 | $response['message'] = $content; |
| 1918 | 2388 | ||
| 2389 | + if ($this->version >= 2) | ||
| 2390 | + { | ||
| 2391 | + $result = $this->get_document_detail($session_id, $document_id); | ||
| 2392 | + $result->value['message'] = $content; | ||
| 2393 | + | ||
| 2394 | + return $result; | ||
| 2395 | + } | ||
| 2396 | + | ||
| 2397 | + | ||
| 1919 | return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response); | 2398 | return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response); |
| 1920 | } | 2399 | } |
| 1921 | 2400 | ||
| @@ -1925,7 +2404,7 @@ class KTWebService | @@ -1925,7 +2404,7 @@ class KTWebService | ||
| 1925 | * @param string $session_id | 2404 | * @param string $session_id |
| 1926 | * @param int $document_id | 2405 | * @param int $document_id |
| 1927 | * @param string $reason | 2406 | * @param string $reason |
| 1928 | - * @return kt_response. status_code can be KTWS_ERR_INVALID_SESSION, KTWS_ERR_INVALID_DOCUMENT or KTWS_SUCCESS | 2407 | + * @return kt_document_detail. status_code can be KTWS_ERR_INVALID_SESSION, KTWS_ERR_INVALID_DOCUMENT or KTWS_SUCCESS |
| 1929 | */ | 2408 | */ |
| 1930 | function undo_document_checkout($session_id, $document_id, $reason) | 2409 | function undo_document_checkout($session_id, $document_id, $reason) |
| 1931 | { | 2410 | { |
| @@ -1962,6 +2441,11 @@ class KTWebService | @@ -1962,6 +2441,11 @@ class KTWebService | ||
| 1962 | 2441 | ||
| 1963 | $response['status_code'] = KTWS_SUCCESS; | 2442 | $response['status_code'] = KTWS_SUCCESS; |
| 1964 | 2443 | ||
| 2444 | + if ($this->version >= 2) | ||
| 2445 | + { | ||
| 2446 | + return $this->get_document_detail($session_id, $document_id); | ||
| 2447 | + } | ||
| 2448 | + | ||
| 1965 | return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response); | 2449 | return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response); |
| 1966 | } | 2450 | } |
| 1967 | 2451 | ||
| @@ -2129,16 +2613,23 @@ class KTWebService | @@ -2129,16 +2613,23 @@ class KTWebService | ||
| 2129 | * @param string $session_id | 2613 | * @param string $session_id |
| 2130 | * @param int $document_id | 2614 | * @param int $document_id |
| 2131 | * @param string $documenttype | 2615 | * @param string $documenttype |
| 2132 | - * @return kt_response | 2616 | + * @return kt_document_detail |
| 2133 | */ | 2617 | */ |
| 2134 | function change_document_type($session_id, $document_id, $documenttype) | 2618 | function change_document_type($session_id, $document_id, $documenttype) |
| 2135 | { | 2619 | { |
| 2136 | $this->debug("change_document_type('$session_id',$document_id,'$documenttype')"); | 2620 | $this->debug("change_document_type('$session_id',$document_id,'$documenttype')"); |
| 2137 | 2621 | ||
| 2138 | $kt = &$this->get_ktapi($session_id ); | 2622 | $kt = &$this->get_ktapi($session_id ); |
| 2623 | + | ||
| 2624 | + $responseType = 'kt_response'; | ||
| 2625 | + if ($this->version >= 2) | ||
| 2626 | + { | ||
| 2627 | + $responseType = 'kt_document_detail'; | ||
| 2628 | + } | ||
| 2629 | + | ||
| 2139 | if (is_array($kt)) | 2630 | if (is_array($kt)) |
| 2140 | { | 2631 | { |
| 2141 | - return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $kt); | 2632 | + return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $kt); |
| 2142 | } | 2633 | } |
| 2143 | $response=array( | 2634 | $response=array( |
| 2144 | 'status_code'=>KTWS_ERR_INVALID_DOCUMENT, | 2635 | 'status_code'=>KTWS_ERR_INVALID_DOCUMENT, |
| @@ -2151,7 +2642,7 @@ class KTWebService | @@ -2151,7 +2642,7 @@ class KTWebService | ||
| 2151 | $response['message'] = $document->getMessage(); | 2642 | $response['message'] = $document->getMessage(); |
| 2152 | 2643 | ||
| 2153 | $this->debug("change_document_type - cannot get documentid $document_id - " . $document->getMessage(), $session_id); | 2644 | $this->debug("change_document_type - cannot get documentid $document_id - " . $document->getMessage(), $session_id); |
| 2154 | - return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response); | 2645 | + return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $response); |
| 2155 | } | 2646 | } |
| 2156 | 2647 | ||
| 2157 | $result = $document->change_document_type($documenttype); | 2648 | $result = $document->change_document_type($documenttype); |
| @@ -2160,11 +2651,16 @@ class KTWebService | @@ -2160,11 +2651,16 @@ class KTWebService | ||
| 2160 | $response['message'] = $result->getMessage(); | 2651 | $response['message'] = $result->getMessage(); |
| 2161 | $this->debug("change_document_type - cannot change type - " . $result->getMessage(), $session_id); | 2652 | $this->debug("change_document_type - cannot change type - " . $result->getMessage(), $session_id); |
| 2162 | 2653 | ||
| 2163 | - return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response); | 2654 | + return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $response); |
| 2164 | } | 2655 | } |
| 2165 | $response['status_code'] = KTWS_SUCCESS; | 2656 | $response['status_code'] = KTWS_SUCCESS; |
| 2166 | 2657 | ||
| 2167 | - return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response); | 2658 | + if ($this->version >= 2) |
| 2659 | + { | ||
| 2660 | + return $this->get_document_detail($session_id, $document_id); | ||
| 2661 | + } | ||
| 2662 | + | ||
| 2663 | + return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $response); | ||
| 2168 | } | 2664 | } |
| 2169 | 2665 | ||
| 2170 | /** | 2666 | /** |
| @@ -2176,7 +2672,7 @@ class KTWebService | @@ -2176,7 +2672,7 @@ class KTWebService | ||
| 2176 | * @param string $reason | 2672 | * @param string $reason |
| 2177 | * @param string $newtitle | 2673 | * @param string $newtitle |
| 2178 | * @param string $newfilename | 2674 | * @param string $newfilename |
| 2179 | - * @return kt_response | 2675 | + * @return kt_document_detail |
| 2180 | */ | 2676 | */ |
| 2181 | function copy_document($session_id,$document_id,$folder_id,$reason,$newtitle,$newfilename) | 2677 | function copy_document($session_id,$document_id,$folder_id,$reason,$newtitle,$newfilename) |
| 2182 | { | 2678 | { |
| @@ -2217,6 +2713,11 @@ class KTWebService | @@ -2217,6 +2713,11 @@ class KTWebService | ||
| 2217 | return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response); | 2713 | return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response); |
| 2218 | } | 2714 | } |
| 2219 | $response['status_code'] = KTWS_SUCCESS; | 2715 | $response['status_code'] = KTWS_SUCCESS; |
| 2716 | + if ($this->version >= 2) | ||
| 2717 | + { | ||
| 2718 | + $new_document_id = $result->documentid; | ||
| 2719 | + return $this->get_document_detail($session_id, $new_document_id, ''); | ||
| 2720 | + } | ||
| 2220 | 2721 | ||
| 2221 | return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response); | 2722 | return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response); |
| 2222 | } | 2723 | } |
| @@ -2286,9 +2787,16 @@ class KTWebService | @@ -2286,9 +2787,16 @@ class KTWebService | ||
| 2286 | { | 2787 | { |
| 2287 | $this->debug("rename_document_title('$session_id',$document_id,'$newtitle')"); | 2788 | $this->debug("rename_document_title('$session_id',$document_id,'$newtitle')"); |
| 2288 | $kt = &$this->get_ktapi($session_id ); | 2789 | $kt = &$this->get_ktapi($session_id ); |
| 2790 | + | ||
| 2791 | + $responseType = 'kt_response'; | ||
| 2792 | + if ($this->version >=2) | ||
| 2793 | + { | ||
| 2794 | + $responseType='kt_document_detail'; | ||
| 2795 | + } | ||
| 2796 | + | ||
| 2289 | if (is_array($kt)) | 2797 | if (is_array($kt)) |
| 2290 | { | 2798 | { |
| 2291 | - return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $kt); | 2799 | + return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $kt); |
| 2292 | } | 2800 | } |
| 2293 | $response=array( | 2801 | $response=array( |
| 2294 | 'status_code'=>KTWS_ERR_INVALID_DOCUMENT, | 2802 | 'status_code'=>KTWS_ERR_INVALID_DOCUMENT, |
| @@ -2300,7 +2808,7 @@ class KTWebService | @@ -2300,7 +2808,7 @@ class KTWebService | ||
| 2300 | { | 2808 | { |
| 2301 | $response['message'] = $document->getMessage(); | 2809 | $response['message'] = $document->getMessage(); |
| 2302 | $this->debug("rename_document_title - cannot get documentid $document_id - " . $document->getMessage(), $session_id); | 2810 | $this->debug("rename_document_title - cannot get documentid $document_id - " . $document->getMessage(), $session_id); |
| 2303 | - return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response); | 2811 | + return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $response); |
| 2304 | } | 2812 | } |
| 2305 | 2813 | ||
| 2306 | $result = $document->rename($newtitle); | 2814 | $result = $document->rename($newtitle); |
| @@ -2308,11 +2816,16 @@ class KTWebService | @@ -2308,11 +2816,16 @@ class KTWebService | ||
| 2308 | { | 2816 | { |
| 2309 | $response['message'] = $result->getMessage(); | 2817 | $response['message'] = $result->getMessage(); |
| 2310 | $this->debug("rename_document_title - cannot rename - " . $result->getMessage(), $session_id); | 2818 | $this->debug("rename_document_title - cannot rename - " . $result->getMessage(), $session_id); |
| 2311 | - return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response); | 2819 | + return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $response); |
| 2312 | } | 2820 | } |
| 2313 | $response['status_code'] = KTWS_SUCCESS; | 2821 | $response['status_code'] = KTWS_SUCCESS; |
| 2314 | 2822 | ||
| 2315 | - return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response); | 2823 | + if ($this->version >= 2) |
| 2824 | + { | ||
| 2825 | + return $this->get_document_detail($session_id, $document_id); | ||
| 2826 | + } | ||
| 2827 | + | ||
| 2828 | + return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $response); | ||
| 2316 | } | 2829 | } |
| 2317 | 2830 | ||
| 2318 | /** | 2831 | /** |
| @@ -2328,9 +2841,15 @@ class KTWebService | @@ -2328,9 +2841,15 @@ class KTWebService | ||
| 2328 | $this->debug("rename_document_filename('$session_id',$document_id,'$newfilename')"); | 2841 | $this->debug("rename_document_filename('$session_id',$document_id,'$newfilename')"); |
| 2329 | 2842 | ||
| 2330 | $kt = &$this->get_ktapi($session_id ); | 2843 | $kt = &$this->get_ktapi($session_id ); |
| 2844 | + $responseType = 'kt_response'; | ||
| 2845 | + if ($this->version >=2) | ||
| 2846 | + { | ||
| 2847 | + $responseType='kt_document_detail'; | ||
| 2848 | + } | ||
| 2849 | + | ||
| 2331 | if (is_array($kt)) | 2850 | if (is_array($kt)) |
| 2332 | { | 2851 | { |
| 2333 | - return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $kt); | 2852 | + return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $kt); |
| 2334 | } | 2853 | } |
| 2335 | $response=array( | 2854 | $response=array( |
| 2336 | 'status_code'=>KTWS_ERR_INVALID_DOCUMENT, | 2855 | 'status_code'=>KTWS_ERR_INVALID_DOCUMENT, |
| @@ -2342,7 +2861,7 @@ class KTWebService | @@ -2342,7 +2861,7 @@ class KTWebService | ||
| 2342 | { | 2861 | { |
| 2343 | $response['message'] = $document->getMessage(); | 2862 | $response['message'] = $document->getMessage(); |
| 2344 | $this->debug("rename_document_filename - cannot get documetid $document_id - " . $document->getMessage(), $session_id); | 2863 | $this->debug("rename_document_filename - cannot get documetid $document_id - " . $document->getMessage(), $session_id); |
| 2345 | - return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response); | 2864 | + return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $response); |
| 2346 | } | 2865 | } |
| 2347 | 2866 | ||
| 2348 | $result = $document->renameFile($newfilename); | 2867 | $result = $document->renameFile($newfilename); |
| @@ -2350,11 +2869,16 @@ class KTWebService | @@ -2350,11 +2869,16 @@ class KTWebService | ||
| 2350 | { | 2869 | { |
| 2351 | $response['message'] = $result->getMessage(); | 2870 | $response['message'] = $result->getMessage(); |
| 2352 | $this->debug("rename_document_filename - cannot rename - " . $result->getMessage(), $session_id); | 2871 | $this->debug("rename_document_filename - cannot rename - " . $result->getMessage(), $session_id); |
| 2353 | - return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response); | 2872 | + return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $response); |
| 2354 | } | 2873 | } |
| 2355 | $response['status_code'] = KTWS_SUCCESS; | 2874 | $response['status_code'] = KTWS_SUCCESS; |
| 2875 | + if ($this->version >= 2) | ||
| 2876 | + { | ||
| 2877 | + return $this->get_document_detail($session_id, $document_id); | ||
| 2878 | + } | ||
| 2356 | 2879 | ||
| 2357 | - return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response); | 2880 | + |
| 2881 | + return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $response); | ||
| 2358 | } | 2882 | } |
| 2359 | 2883 | ||
| 2360 | /** | 2884 | /** |
| @@ -2364,17 +2888,25 @@ class KTWebService | @@ -2364,17 +2888,25 @@ class KTWebService | ||
| 2364 | * @param int $document_id | 2888 | * @param int $document_id |
| 2365 | * @param string $username | 2889 | * @param string $username |
| 2366 | * @param string $reason | 2890 | * @param string $reason |
| 2367 | - * @return kt_response. status_code can be KTWS_ERR_INVALID_SESSION, KTWS_ERR_INVALID_DOCUMENT or KTWS_SUCCESS | 2891 | + * @return kt_document_detail. status_code can be KTWS_ERR_INVALID_SESSION, KTWS_ERR_INVALID_DOCUMENT or KTWS_SUCCESS |
| 2368 | */ | 2892 | */ |
| 2369 | function change_document_owner($session_id, $document_id, $username, $reason) | 2893 | function change_document_owner($session_id, $document_id, $username, $reason) |
| 2370 | { | 2894 | { |
| 2371 | $this->debug("change_document_owner('$session_id',$document_id,'$username','$reason')"); | 2895 | $this->debug("change_document_owner('$session_id',$document_id,'$username','$reason')"); |
| 2372 | 2896 | ||
| 2373 | $kt = &$this->get_ktapi($session_id ); | 2897 | $kt = &$this->get_ktapi($session_id ); |
| 2898 | + | ||
| 2899 | + $responseType = 'kt_response'; | ||
| 2900 | + if ($this->version >= 2) | ||
| 2901 | + { | ||
| 2902 | + $responseType = 'kt_document_detail'; | ||
| 2903 | + } | ||
| 2904 | + | ||
| 2374 | if (is_array($kt)) | 2905 | if (is_array($kt)) |
| 2375 | { | 2906 | { |
| 2376 | - return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $kt); | 2907 | + return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $kt); |
| 2377 | } | 2908 | } |
| 2909 | + | ||
| 2378 | $response=array( | 2910 | $response=array( |
| 2379 | 'status_code'=>KTWS_ERR_INVALID_DOCUMENT, | 2911 | 'status_code'=>KTWS_ERR_INVALID_DOCUMENT, |
| 2380 | 'message'=>'' | 2912 | 'message'=>'' |
| @@ -2385,7 +2917,7 @@ class KTWebService | @@ -2385,7 +2917,7 @@ class KTWebService | ||
| 2385 | { | 2917 | { |
| 2386 | $response['message'] = $document->getMessage(); | 2918 | $response['message'] = $document->getMessage(); |
| 2387 | $this->debug("change_document_owner - cannot get documetid $document_id - " . $document->getMessage(), $session_id); | 2919 | $this->debug("change_document_owner - cannot get documetid $document_id - " . $document->getMessage(), $session_id); |
| 2388 | - return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response); | 2920 | + return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $response); |
| 2389 | } | 2921 | } |
| 2390 | 2922 | ||
| 2391 | $result = $document->change_owner($username, $reason); | 2923 | $result = $document->change_owner($username, $reason); |
| @@ -2393,11 +2925,16 @@ class KTWebService | @@ -2393,11 +2925,16 @@ class KTWebService | ||
| 2393 | { | 2925 | { |
| 2394 | $response['message'] = $result->getMessage(); | 2926 | $response['message'] = $result->getMessage(); |
| 2395 | $this->debug("change_document_owner - cannot change owner - " . $result->getMessage(), $session_id); | 2927 | $this->debug("change_document_owner - cannot change owner - " . $result->getMessage(), $session_id); |
| 2396 | - return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response); | 2928 | + return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $response); |
| 2397 | } | 2929 | } |
| 2398 | $response['status_code'] = KTWS_SUCCESS; | 2930 | $response['status_code'] = KTWS_SUCCESS; |
| 2399 | 2931 | ||
| 2400 | - return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response); | 2932 | + if ($this->version >= 2) |
| 2933 | + { | ||
| 2934 | + return $this->get_document_detail($session_id, $document_id); | ||
| 2935 | + } | ||
| 2936 | + | ||
| 2937 | + return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $response); | ||
| 2401 | } | 2938 | } |
| 2402 | 2939 | ||
| 2403 | /** | 2940 | /** |
| @@ -2406,16 +2943,22 @@ class KTWebService | @@ -2406,16 +2943,22 @@ class KTWebService | ||
| 2406 | * @param string $session_id | 2943 | * @param string $session_id |
| 2407 | * @param int $document_id | 2944 | * @param int $document_id |
| 2408 | * @param string $workflow | 2945 | * @param string $workflow |
| 2409 | - * @return kt_response | 2946 | + * @return kt_document_detail |
| 2410 | */ | 2947 | */ |
| 2411 | function start_document_workflow($session_id,$document_id,$workflow) | 2948 | function start_document_workflow($session_id,$document_id,$workflow) |
| 2412 | { | 2949 | { |
| 2413 | $this->debug("start_document_workflow('$session_id',$document_id,'$workflow')"); | 2950 | $this->debug("start_document_workflow('$session_id',$document_id,'$workflow')"); |
| 2414 | 2951 | ||
| 2415 | $kt = &$this->get_ktapi($session_id ); | 2952 | $kt = &$this->get_ktapi($session_id ); |
| 2953 | + $responseType = 'kt_response'; | ||
| 2954 | + if ($this->version >= 2) | ||
| 2955 | + { | ||
| 2956 | + $responseType = 'kt_document_detail'; | ||
| 2957 | + } | ||
| 2958 | + | ||
| 2416 | if (is_array($kt)) | 2959 | if (is_array($kt)) |
| 2417 | { | 2960 | { |
| 2418 | - return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $kt); | 2961 | + return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $kt); |
| 2419 | } | 2962 | } |
| 2420 | $response=array( | 2963 | $response=array( |
| 2421 | 'status_code'=>KTWS_ERR_INVALID_DOCUMENT, | 2964 | 'status_code'=>KTWS_ERR_INVALID_DOCUMENT, |
| @@ -2427,7 +2970,7 @@ class KTWebService | @@ -2427,7 +2970,7 @@ class KTWebService | ||
| 2427 | { | 2970 | { |
| 2428 | $response['message'] = $document->getMessage(); | 2971 | $response['message'] = $document->getMessage(); |
| 2429 | $this->debug("start_document_workflow - cannot get documentid $document_id - " . $document->getMessage(), $session_id); | 2972 | $this->debug("start_document_workflow - cannot get documentid $document_id - " . $document->getMessage(), $session_id); |
| 2430 | - return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response); | 2973 | + return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $response); |
| 2431 | } | 2974 | } |
| 2432 | 2975 | ||
| 2433 | $result = &$document->start_workflow($workflow); | 2976 | $result = &$document->start_workflow($workflow); |
| @@ -2435,11 +2978,16 @@ class KTWebService | @@ -2435,11 +2978,16 @@ class KTWebService | ||
| 2435 | { | 2978 | { |
| 2436 | $response['message'] = $result->getMessage(); | 2979 | $response['message'] = $result->getMessage(); |
| 2437 | $this->debug("start_document_workflow - cannot start workflow - " . $result->getMessage(), $session_id); | 2980 | $this->debug("start_document_workflow - cannot start workflow - " . $result->getMessage(), $session_id); |
| 2438 | - return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response); | 2981 | + return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $response); |
| 2439 | } | 2982 | } |
| 2440 | $response['status_code'] = KTWS_SUCCESS; | 2983 | $response['status_code'] = KTWS_SUCCESS; |
| 2441 | 2984 | ||
| 2442 | - return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response); | 2985 | + if ($this->version >= 2) |
| 2986 | + { | ||
| 2987 | + return $this->get_document_detail($session_id, $document_id); | ||
| 2988 | + } | ||
| 2989 | + | ||
| 2990 | + return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $response); | ||
| 2443 | } | 2991 | } |
| 2444 | 2992 | ||
| 2445 | /** | 2993 | /** |
| @@ -2447,15 +2995,20 @@ class KTWebService | @@ -2447,15 +2995,20 @@ class KTWebService | ||
| 2447 | * | 2995 | * |
| 2448 | * @param string $session_id | 2996 | * @param string $session_id |
| 2449 | * @param int $document_id | 2997 | * @param int $document_id |
| 2450 | - * @return kt_response | 2998 | + * @return kt_document_detail |
| 2451 | */ | 2999 | */ |
| 2452 | function delete_document_workflow($session_id,$document_id) | 3000 | function delete_document_workflow($session_id,$document_id) |
| 2453 | { | 3001 | { |
| 2454 | $this->debug("delete_document_workflow('$session_id',$document_id)"); | 3002 | $this->debug("delete_document_workflow('$session_id',$document_id)"); |
| 2455 | $kt = &$this->get_ktapi($session_id ); | 3003 | $kt = &$this->get_ktapi($session_id ); |
| 3004 | + $responseType = 'kt_response'; | ||
| 3005 | + if ($this->version >= 2) | ||
| 3006 | + { | ||
| 3007 | + $responseType = 'kt_document_detail'; | ||
| 3008 | + } | ||
| 2456 | if (is_array($kt)) | 3009 | if (is_array($kt)) |
| 2457 | { | 3010 | { |
| 2458 | - return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $kt); | 3011 | + return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $kt); |
| 2459 | } | 3012 | } |
| 2460 | $response=array( | 3013 | $response=array( |
| 2461 | 'status_code'=>KTWS_ERR_INVALID_DOCUMENT, | 3014 | 'status_code'=>KTWS_ERR_INVALID_DOCUMENT, |
| @@ -2467,7 +3020,7 @@ class KTWebService | @@ -2467,7 +3020,7 @@ class KTWebService | ||
| 2467 | { | 3020 | { |
| 2468 | $response['message'] = $document->getMessage(); | 3021 | $response['message'] = $document->getMessage(); |
| 2469 | $this->debug("delete_document_workflow - cannot get documentid $document_id - " . $document->getMessage(), $session_id); | 3022 | $this->debug("delete_document_workflow - cannot get documentid $document_id - " . $document->getMessage(), $session_id); |
| 2470 | - return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response); | 3023 | + return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $response); |
| 2471 | } | 3024 | } |
| 2472 | 3025 | ||
| 2473 | $result = $document->delete_workflow(); | 3026 | $result = $document->delete_workflow(); |
| @@ -2478,8 +3031,12 @@ class KTWebService | @@ -2478,8 +3031,12 @@ class KTWebService | ||
| 2478 | return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response); | 3031 | return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response); |
| 2479 | } | 3032 | } |
| 2480 | $response['status_code'] = KTWS_SUCCESS; | 3033 | $response['status_code'] = KTWS_SUCCESS; |
| 3034 | + if ($this->version >= 2) | ||
| 3035 | + { | ||
| 3036 | + return $this->get_document_detail($session_id, $document_id); | ||
| 3037 | + } | ||
| 2481 | 3038 | ||
| 2482 | - return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response); | 3039 | + return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $response); |
| 2483 | } | 3040 | } |
| 2484 | 3041 | ||
| 2485 | /** | 3042 | /** |
| @@ -2496,9 +3053,15 @@ class KTWebService | @@ -2496,9 +3053,15 @@ class KTWebService | ||
| 2496 | $this->debug("perform_document_workflow_transition('$session_id',$document_id,'$transition','$reason')"); | 3053 | $this->debug("perform_document_workflow_transition('$session_id',$document_id,'$transition','$reason')"); |
| 2497 | 3054 | ||
| 2498 | $kt = &$this->get_ktapi($session_id ); | 3055 | $kt = &$this->get_ktapi($session_id ); |
| 3056 | + $responseType = 'kt_response'; | ||
| 3057 | + if ($this->version >= 2) | ||
| 3058 | + { | ||
| 3059 | + $responseType = 'kt_document_detail'; | ||
| 3060 | + } | ||
| 3061 | + | ||
| 2499 | if (is_array($kt)) | 3062 | if (is_array($kt)) |
| 2500 | { | 3063 | { |
| 2501 | - return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $kt); | 3064 | + return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $kt); |
| 2502 | } | 3065 | } |
| 2503 | $response=array( | 3066 | $response=array( |
| 2504 | 'status_code'=>KTWS_ERR_INVALID_DOCUMENT, | 3067 | 'status_code'=>KTWS_ERR_INVALID_DOCUMENT, |
| @@ -2510,7 +3073,7 @@ class KTWebService | @@ -2510,7 +3073,7 @@ class KTWebService | ||
| 2510 | { | 3073 | { |
| 2511 | $response['message'] = $document->getMessage(); | 3074 | $response['message'] = $document->getMessage(); |
| 2512 | $this->debug("perform_document_workflow_transition - cannot get document - " . $document->getMessage(), $session_id); | 3075 | $this->debug("perform_document_workflow_transition - cannot get document - " . $document->getMessage(), $session_id); |
| 2513 | - return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response); | 3076 | + return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $response); |
| 2514 | } | 3077 | } |
| 2515 | 3078 | ||
| 2516 | $result = $document->perform_workflow_transition($transition,$reason); | 3079 | $result = $document->perform_workflow_transition($transition,$reason); |
| @@ -2518,11 +3081,16 @@ class KTWebService | @@ -2518,11 +3081,16 @@ class KTWebService | ||
| 2518 | { | 3081 | { |
| 2519 | $response['message'] = $result->getMessage(); | 3082 | $response['message'] = $result->getMessage(); |
| 2520 | $this->debug("perform_document_workflow_transition - cannot perform transition - " . $result->getMessage(), $session_id); | 3083 | $this->debug("perform_document_workflow_transition - cannot perform transition - " . $result->getMessage(), $session_id); |
| 2521 | - return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response); | 3084 | + return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $response); |
| 2522 | } | 3085 | } |
| 2523 | $response['status_code'] = KTWS_SUCCESS; | 3086 | $response['status_code'] = KTWS_SUCCESS; |
| 2524 | 3087 | ||
| 2525 | - return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response); | 3088 | + if ($this->version >= 2) |
| 3089 | + { | ||
| 3090 | + return $this->get_document_detail($session_id, $document_id); | ||
| 3091 | + } | ||
| 3092 | + | ||
| 3093 | + return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $response); | ||
| 2526 | } | 3094 | } |
| 2527 | 3095 | ||
| 2528 | /** | 3096 | /** |
| @@ -2814,16 +3382,22 @@ class KTWebService | @@ -2814,16 +3382,22 @@ class KTWebService | ||
| 2814 | * @param string $session_id | 3382 | * @param string $session_id |
| 2815 | * @param int $document_id | 3383 | * @param int $document_id |
| 2816 | * @param array $metadata | 3384 | * @param array $metadata |
| 2817 | - * @return kt_response | 3385 | + * @return kt_document_detail |
| 2818 | */ | 3386 | */ |
| 2819 | - function update_document_metadata($session_id,$document_id,$metadata) | 3387 | + function update_document_metadata($session_id,$document_id,$metadata, $sysdata=null) |
| 2820 | { | 3388 | { |
| 2821 | - $this->debug("update_document_metadata('$session_id',$document_id,$metadata)"); | 3389 | + $this->debug("update_document_metadata('$session_id',$document_id,$metadata, $sysdata)"); |
| 2822 | 3390 | ||
| 2823 | $kt = &$this->get_ktapi($session_id ); | 3391 | $kt = &$this->get_ktapi($session_id ); |
| 3392 | + $responseType = 'kt_response'; | ||
| 3393 | + if ($this->version >= 2) | ||
| 3394 | + { | ||
| 3395 | + $responseType = 'kt_document_detail'; | ||
| 3396 | + } | ||
| 3397 | + | ||
| 2824 | if (is_array($kt)) | 3398 | if (is_array($kt)) |
| 2825 | { | 3399 | { |
| 2826 | - return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $kt); | 3400 | + return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $kt); |
| 2827 | } | 3401 | } |
| 2828 | $response=array( | 3402 | $response=array( |
| 2829 | 'status_code'=>KTWS_ERR_INVALID_DOCUMENT, | 3403 | 'status_code'=>KTWS_ERR_INVALID_DOCUMENT, |
| @@ -2835,7 +3409,7 @@ class KTWebService | @@ -2835,7 +3409,7 @@ class KTWebService | ||
| 2835 | { | 3409 | { |
| 2836 | $response['message'] = $document->getMessage(); | 3410 | $response['message'] = $document->getMessage(); |
| 2837 | $this->debug("update_document_metadata - cannot get documentid $document_id - " . $document->getMessage(), $session_id); | 3411 | $this->debug("update_document_metadata - cannot get documentid $document_id - " . $document->getMessage(), $session_id); |
| 2838 | - return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response); | 3412 | + return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $response); |
| 2839 | } | 3413 | } |
| 2840 | 3414 | ||
| 2841 | $result = $document->update_metadata($metadata); | 3415 | $result = $document->update_metadata($metadata); |
| @@ -2843,12 +3417,26 @@ class KTWebService | @@ -2843,12 +3417,26 @@ class KTWebService | ||
| 2843 | { | 3417 | { |
| 2844 | $response['message'] = $result->getMessage(); | 3418 | $response['message'] = $result->getMessage(); |
| 2845 | $this->debug("update_document_metadata - cannot update metadata - " . $result->getMessage(), $session_id); | 3419 | $this->debug("update_document_metadata - cannot update metadata - " . $result->getMessage(), $session_id); |
| 2846 | - return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response); | 3420 | + return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $response); |
| 2847 | } | 3421 | } |
| 2848 | 3422 | ||
| 3423 | + | ||
| 3424 | + if ($this->version >= 2) | ||
| 3425 | + { | ||
| 3426 | + $result = $document->update_sysdata($sysdata); | ||
| 3427 | + if (PEAR::isError($result)) | ||
| 3428 | + { | ||
| 3429 | + $response['message'] = $result->getMessage(); | ||
| 3430 | + $this->debug("update_document_metadata - cannot update sysdata - " . $result->getMessage(), $session_id); | ||
| 3431 | + return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $response); | ||
| 3432 | + } | ||
| 3433 | + | ||
| 3434 | + | ||
| 3435 | + return $this->get_document_detail($session_id, $document_id, 'M'); | ||
| 3436 | + } | ||
| 2849 | $response['status_code'] = KTWS_SUCCESS; | 3437 | $response['status_code'] = KTWS_SUCCESS; |
| 2850 | 3438 | ||
| 2851 | - return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $response); | 3439 | + return new SOAP_Value('return',"{urn:$this->namespace}$responseType", $response); |
| 2852 | 3440 | ||
| 2853 | } | 3441 | } |
| 2854 | 3442 | ||
| @@ -3149,7 +3737,7 @@ class KTWebService | @@ -3149,7 +3737,7 @@ class KTWebService | ||
| 3149 | $response=array( | 3737 | $response=array( |
| 3150 | 'status_code'=>KTWS_ERR_INVALID_DOCUMENT, | 3738 | 'status_code'=>KTWS_ERR_INVALID_DOCUMENT, |
| 3151 | 'message'=>'', | 3739 | 'message'=>'', |
| 3152 | - 'parent_document_id' => $document_id, | 3740 | + 'parent_document_id' => (int) $document_id, |
| 3153 | 'links'=>array() | 3741 | 'links'=>array() |
| 3154 | ); | 3742 | ); |
| 3155 | 3743 | ||
| @@ -3162,7 +3750,8 @@ class KTWebService | @@ -3162,7 +3750,8 @@ class KTWebService | ||
| 3162 | } | 3750 | } |
| 3163 | 3751 | ||
| 3164 | $links = $document->get_linked_documents(); | 3752 | $links = $document->get_linked_documents(); |
| 3165 | - $response['links'] = $links; | 3753 | + $response['links'] = new SOAP_Value('links',"{urn:$this->namespace}kt_linked_documents", $links); |
| 3754 | + $response['status_code'] = KTWS_SUCCESS; | ||
| 3166 | 3755 | ||
| 3167 | return new SOAP_Value('return',"{urn:$this->namespace}kt_linked_document_response", $response); | 3756 | return new SOAP_Value('return',"{urn:$this->namespace}kt_linked_document_response", $response); |
| 3168 | } | 3757 | } |
| @@ -3364,65 +3953,34 @@ class KTWebService | @@ -3364,65 +3953,34 @@ class KTWebService | ||
| 3364 | return new SOAP_Value('return',"{urn:$this->namespace}kt_search_response", $kt); | 3953 | return new SOAP_Value('return',"{urn:$this->namespace}kt_search_response", $kt); |
| 3365 | } | 3954 | } |
| 3366 | $response=array( | 3955 | $response=array( |
| 3367 | - 'status_code'=>KTWS_ERR_INVALID_DOCUMENT, | 3956 | + 'status_code'=>KTWS_ERR_PROBLEM, |
| 3368 | 'message'=>'', | 3957 | 'message'=>'', |
| 3369 | 'hits'=>array() | 3958 | 'hits'=>array() |
| 3370 | ); | 3959 | ); |
| 3371 | 3960 | ||
| 3372 | - $noText = (stripos($options,'notext') !== false); | ||
| 3373 | - $results = array(); | ||
| 3374 | - | ||
| 3375 | - try | 3961 | + if (!defined('HAS_SEARCH_FUNCTIONALITY')) |
| 3376 | { | 3962 | { |
| 3377 | - $expr = parseExpression($query); | ||
| 3378 | - | ||
| 3379 | - $rs = $expr->evaluate(); | ||
| 3380 | - usort($rs, 'rank_compare'); | ||
| 3381 | - | ||
| 3382 | - $results = array(); | ||
| 3383 | - foreach($rs as $hit) | ||
| 3384 | - { | ||
| 3385 | - $item = array( | ||
| 3386 | - 'document_id' => (int) $hit->DocumentID, | ||
| 3387 | - 'title' => (string) $hit->Title, | ||
| 3388 | - 'relevance' => (float) $hit->Rank, | ||
| 3389 | - 'text' => (string) $noText?'':$hit->Text, | ||
| 3390 | - 'filesize' => (int) $hit->Filesize, | ||
| 3391 | - 'fullpath' => (string) $hit->FullPath, | ||
| 3392 | - 'version' => (string) $hit->Version, | ||
| 3393 | - 'filename' => (string) $hit->Filename, | ||
| 3394 | - 'checked_out_by' => (string) $hit->CheckedOutUser, | ||
| 3395 | - 'checked_out_date' => (string) $hit->DateCheckedOut, | ||
| 3396 | - 'is_available' => (bool) $hit->IsAvailable, | ||
| 3397 | - 'workflow' => (string) $hit->Workflow, | ||
| 3398 | - 'workflow_state' => (string) $hit->WorkflowState, | ||
| 3399 | - 'folder_id' => (int) $hit->FolderId, | ||
| 3400 | - 'mime_type' => (string) $hit->MimeType, | ||
| 3401 | - 'modified_by' => (string) $hit->ModifiedBy, | ||
| 3402 | - 'modified_date' => (string) $hit->DateModified, | ||
| 3403 | - 'created_by' => (string) $hit->CreatedBy, | ||
| 3404 | - 'created_date' => (string) $hit->DateCreated, | ||
| 3405 | - 'owner' => (string) $hit->Owner, | ||
| 3406 | - 'is_immutable'=> (bool) $hit->Immutable, | ||
| 3407 | - 'status' => (string) $hit->Status | ||
| 3408 | - ); | ||
| 3409 | - | ||
| 3410 | - $item = new SOAP_Value('item',"{urn:$this->namespace}kt_search_result_item", $item); | ||
| 3411 | - $results[] = $item; | ||
| 3412 | - | ||
| 3413 | - } | 3963 | + $response['message'] = _kt('Search has not been implemented for this version of KnowledgeTree'); |
| 3964 | + return new SOAP_Value('return',"{urn:$this->namespace}kt_search_response", $response); | ||
| 3965 | + } | ||
| 3414 | 3966 | ||
| 3415 | - $response['message'] = ''; | 3967 | + $results = processSearchExpression($query); |
| 3968 | + if (PEAR::isError($results)) | ||
| 3969 | + { | ||
| 3970 | + $response['message'] = _kt('Could not process query.') . $results->getMessage(); | ||
| 3971 | + $results = array(); | ||
| 3972 | + } | ||
| 3973 | + else | ||
| 3974 | + { | ||
| 3975 | + foreach($results as $key=>$item) | ||
| 3976 | + { | ||
| 3977 | + $results[$key] = new SOAP_Value('item',"{urn:$this->namespace}kt_search_result_item", $item); | ||
| 3978 | + } | ||
| 3979 | + $response['message'] = ''; | ||
| 3416 | $response['status_code'] = KTWS_SUCCESS; | 3980 | $response['status_code'] = KTWS_SUCCESS; |
| 3417 | - } | ||
| 3418 | - catch(Exception $e) | ||
| 3419 | - { | ||
| 3420 | - $this->debug("search - exception " . $e->getMessage(), $session_id); | ||
| 3421 | 3981 | ||
| 3422 | - $results = array(); | ||
| 3423 | - $response['message'] = _kt('Could not process query.') . $e->getMessage(); | ||
| 3424 | - } | ||
| 3425 | - $response['hits'] = new SOAP_Value('hits',"{urn:$this->namespace}kt_search_results", $results); | 3982 | + } |
| 3983 | + $response['hits'] = new SOAP_Value('hits',"{urn:$this->namespace}kt_search_results", $results); | ||
| 3426 | 3984 | ||
| 3427 | return new SOAP_Value('return',"{urn:$this->namespace}kt_search_response", $response); | 3985 | return new SOAP_Value('return',"{urn:$this->namespace}kt_search_response", $response); |
| 3428 | } | 3986 | } |
| @@ -3435,13 +3993,17 @@ class KTWebService | @@ -3435,13 +3993,17 @@ class KTWebService | ||
| 3435 | */ | 3993 | */ |
| 3436 | function run() | 3994 | function run() |
| 3437 | { | 3995 | { |
| 3996 | + ob_start(); | ||
| 3438 | $server = new SOAP_Server(); | 3997 | $server = new SOAP_Server(); |
| 3439 | 3998 | ||
| 3440 | $server->addObjectMap($this, 'http://schemas.xmlsoap.org/soap/envelope/'); | 3999 | $server->addObjectMap($this, 'http://schemas.xmlsoap.org/soap/envelope/'); |
| 4000 | + $request = 'Not Set'; | ||
| 3441 | 4001 | ||
| 3442 | if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD']=='POST') | 4002 | if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD']=='POST') |
| 3443 | { | 4003 | { |
| 3444 | - $server->service(file_get_contents("php://input")); | 4004 | + $request = file_get_contents("php://input"); |
| 4005 | + | ||
| 4006 | + $server->service($request); | ||
| 3445 | } | 4007 | } |
| 3446 | else | 4008 | else |
| 3447 | { | 4009 | { |
| @@ -3457,6 +4019,12 @@ class KTWebService | @@ -3457,6 +4019,12 @@ class KTWebService | ||
| 3457 | echo $disco->getDISCO(); | 4019 | echo $disco->getDISCO(); |
| 3458 | } | 4020 | } |
| 3459 | } | 4021 | } |
| 4022 | + $capture = ob_get_flush(); | ||
| 4023 | + $this->debug($request,'request', 5); | ||
| 4024 | + $this->debug($capture,'response',5); | ||
| 4025 | + global $_KT_starttime; | ||
| 4026 | + $time = number_format(KTUtil::getBenchmarkTime() - $_KT_starttime,2); | ||
| 4027 | + $this->debug($time, 'time from start',4); | ||
| 3460 | } | 4028 | } |
| 3461 | 4029 | ||
| 3462 | function __dispatch($methodname) | 4030 | function __dispatch($methodname) |
| @@ -3470,6 +4038,7 @@ class KTWebService | @@ -3470,6 +4038,7 @@ class KTWebService | ||
| 3470 | 4038 | ||
| 3471 | } | 4039 | } |
| 3472 | 4040 | ||
| 4041 | + | ||
| 3473 | $webservice = new KTWebService(); | 4042 | $webservice = new KTWebService(); |
| 3474 | $webservice->run(); | 4043 | $webservice->run(); |
| 3475 | 4044 |
lib/browse/browseutil.inc.php
| @@ -7,32 +7,32 @@ | @@ -7,32 +7,32 @@ | ||
| 7 | * KnowledgeTree Open Source Edition | 7 | * KnowledgeTree Open Source Edition |
| 8 | * Document Management Made Simple | 8 | * Document Management Made Simple |
| 9 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited | 9 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited |
| 10 | - * | 10 | + * |
| 11 | * This program is free software; you can redistribute it and/or modify it under | 11 | * This program is free software; you can redistribute it and/or modify it under |
| 12 | * the terms of the GNU General Public License version 3 as published by the | 12 | * the terms of the GNU General Public License version 3 as published by the |
| 13 | * Free Software Foundation. | 13 | * Free Software Foundation. |
| 14 | - * | 14 | + * |
| 15 | * This program is distributed in the hope that it will be useful, but WITHOUT | 15 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 16 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 16 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 17 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | 17 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 18 | * details. | 18 | * details. |
| 19 | - * | 19 | + * |
| 20 | * You should have received a copy of the GNU General Public License | 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 21 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 22 | - * | 22 | + * |
| 23 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, | 23 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, |
| 24 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. | 24 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. |
| 25 | - * | 25 | + * |
| 26 | * The interactive user interfaces in modified source and object code versions | 26 | * The interactive user interfaces in modified source and object code versions |
| 27 | * of this program must display Appropriate Legal Notices, as required under | 27 | * of this program must display Appropriate Legal Notices, as required under |
| 28 | * Section 5 of the GNU General Public License version 3. | 28 | * Section 5 of the GNU General Public License version 3. |
| 29 | - * | 29 | + * |
| 30 | * In accordance with Section 7(b) of the GNU General Public License version 3, | 30 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 31 | * these Appropriate Legal Notices must retain the display of the "Powered by | 31 | * these Appropriate Legal Notices must retain the display of the "Powered by |
| 32 | - * KnowledgeTree" logo and retain the original copyright notice. If the display of the | 32 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the |
| 33 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | 33 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices |
| 34 | - * must display the words "Powered by KnowledgeTree" and retain the original | ||
| 35 | - * copyright notice. | 34 | + * must display the words "Powered by KnowledgeTree" and retain the original |
| 35 | + * copyright notice. | ||
| 36 | * Contributor( s): ______________________________________ | 36 | * Contributor( s): ______________________________________ |
| 37 | */ | 37 | */ |
| 38 | 38 | ||
| @@ -381,20 +381,26 @@ class KTBrowseUtil { | @@ -381,20 +381,26 @@ class KTBrowseUtil { | ||
| 381 | } | 381 | } |
| 382 | $sPermissionDescriptors = DBUtil::paramArray($aPermissionDescriptors); | 382 | $sPermissionDescriptors = DBUtil::paramArray($aPermissionDescriptors); |
| 383 | 383 | ||
| 384 | + $oPermission = KTPermission::getByName('ktcore.permissions.read'); | ||
| 385 | + $oPermission2 = KTPermission::getByName('ktcore.permissions.folder_details'); | ||
| 386 | + $aPermissionIds = array($oPermission->getId(), $oPermission->getId(), $oPermission2->getId(), $oPermission2->getId()); | ||
| 387 | + | ||
| 384 | $sFoldersTable = KTUtil::getTableName('folders'); | 388 | $sFoldersTable = KTUtil::getTableName('folders'); |
| 385 | $sPLTable = KTUtil::getTableName('permission_lookups'); | 389 | $sPLTable = KTUtil::getTableName('permission_lookups'); |
| 386 | $sPLATable = KTUtil::getTableName('permission_lookup_assignments'); | 390 | $sPLATable = KTUtil::getTableName('permission_lookup_assignments'); |
| 387 | - $oPermission = KTPermission::getByName('ktcore.permissions.read'); | ||
| 388 | $sQuery = "SELECT DISTINCT F.id AS id FROM | 391 | $sQuery = "SELECT DISTINCT F.id AS id FROM |
| 389 | $sFoldersTable AS F | 392 | $sFoldersTable AS F |
| 390 | - LEFT JOIN $sPLTable AS PL ON F.permission_lookup_id = PL.id LEFT JOIN $sPLATable AS PLA ON PLA.permission_lookup_id = PL.id AND PLA.permission_id = ? | 393 | + LEFT JOIN $sPLTable AS PL ON F.permission_lookup_id = PL.id |
| 394 | + LEFT JOIN $sPLATable AS PLA ON PLA.permission_lookup_id = PL.id AND (PLA.permission_id = ? || PLA.permission_id = ?) | ||
| 395 | + | ||
| 391 | LEFT JOIN $sFoldersTable AS F2 ON F.parent_id = F2.id | 396 | LEFT JOIN $sFoldersTable AS F2 ON F.parent_id = F2.id |
| 392 | - LEFT JOIN $sPLTable AS PL2 ON F2.permission_lookup_id = PL2.id LEFT JOIN $sPLATable AS PLA2 ON PLA2.permission_lookup_id = PL2.id AND PLA2.permission_id = ? | 397 | + LEFT JOIN $sPLTable AS PL2 ON F2.permission_lookup_id = PL2.id |
| 398 | + LEFT JOIN $sPLATable AS PLA2 ON PLA2.permission_lookup_id = PL2.id AND (PLA2.permission_id = ? || PLA.permission_id = ?) | ||
| 393 | WHERE | 399 | WHERE |
| 394 | PLA.permission_descriptor_id IN ($sPermissionDescriptors) | 400 | PLA.permission_descriptor_id IN ($sPermissionDescriptors) |
| 395 | AND F2.id <> 1 | 401 | AND F2.id <> 1 |
| 396 | AND NOT (PLA2.permission_descriptor_id IN ($sPermissionDescriptors))"; | 402 | AND NOT (PLA2.permission_descriptor_id IN ($sPermissionDescriptors))"; |
| 397 | - $aParams = kt_array_merge(array($oPermission->getId(), $oPermission->getId()), $aPermissionDescriptors, $aPermissionDescriptors); | 403 | + $aParams = kt_array_merge($aPermissionIds, $aPermissionDescriptors, $aPermissionDescriptors); |
| 398 | $res = DBUtil::getResultArrayKey(array($sQuery, $aParams), 'id'); | 404 | $res = DBUtil::getResultArrayKey(array($sQuery, $aParams), 'id'); |
| 399 | 405 | ||
| 400 | if (PEAR::isError($res)) { | 406 | if (PEAR::isError($res)) { |
lib/documentmanagement/documentutil.inc.php
| @@ -638,14 +638,14 @@ class KTDocumentUtil { | @@ -638,14 +638,14 @@ class KTDocumentUtil { | ||
| 638 | return $oDocument; | 638 | return $oDocument; |
| 639 | } | 639 | } |
| 640 | // }}} | 640 | // }}} |
| 641 | - | 641 | + |
| 642 | function generateNewDocumentFilename($sDocFilename){ | 642 | function generateNewDocumentFilename($sDocFilename){ |
| 643 | if(preg_match("/\([0-9]+\)(\.[^\.]+){1,}$/", $sDocFilename)){ | 643 | if(preg_match("/\([0-9]+\)(\.[^\.]+){1,}$/", $sDocFilename)){ |
| 644 | preg_match("/\([0-9]+\)\./", $sDocFilename, $matches); | 644 | preg_match("/\([0-9]+\)\./", $sDocFilename, $matches); |
| 645 | $new_one = substr($matches[0], 1); | 645 | $new_one = substr($matches[0], 1); |
| 646 | $new_two = explode(')', $new_one); | 646 | $new_two = explode(')', $new_one); |
| 647 | $new = $new_two[0]+1; | 647 | $new = $new_two[0]+1; |
| 648 | - | 648 | + |
| 649 | $pattern[0] = '/\([0-9]+\)\./'; | 649 | $pattern[0] = '/\([0-9]+\)\./'; |
| 650 | $replacement[0] = ' ('.$new.').'; | 650 | $replacement[0] = ' ('.$new.').'; |
| 651 | $sFilename = preg_replace($pattern, $replacement, $sDocFilename); | 651 | $sFilename = preg_replace($pattern, $replacement, $sDocFilename); |
| @@ -657,27 +657,27 @@ class KTDocumentUtil { | @@ -657,27 +657,27 @@ class KTDocumentUtil { | ||
| 657 | } | 657 | } |
| 658 | $sFilename = $prefix.$suffix; | 658 | $sFilename = $prefix.$suffix; |
| 659 | } | 659 | } |
| 660 | - | 660 | + |
| 661 | return $sFilename; | 661 | return $sFilename; |
| 662 | } | 662 | } |
| 663 | - | ||
| 664 | - function generateNewDocumentName($sDocName){ | 663 | + |
| 664 | + function generateNewDocumentName($sDocName){ | ||
| 665 | if(preg_match("/\([0-9]+\)$/", $sDocName)){ | 665 | if(preg_match("/\([0-9]+\)$/", $sDocName)){ |
| 666 | preg_match("/\([0-9]+\)$/", $sDocName, $matches); | 666 | preg_match("/\([0-9]+\)$/", $sDocName, $matches); |
| 667 | $new_one = substr($matches[0], 1); | 667 | $new_one = substr($matches[0], 1); |
| 668 | $new_two = explode(')', $new_one); | 668 | $new_two = explode(')', $new_one); |
| 669 | $new = $new_two[0]+1; | 669 | $new = $new_two[0]+1; |
| 670 | - | 670 | + |
| 671 | $pattern[0] = '/\([0-9]+\)$/'; | 671 | $pattern[0] = '/\([0-9]+\)$/'; |
| 672 | $replacement[0] = '('.$new.')'; | 672 | $replacement[0] = '('.$new.')'; |
| 673 | $sName = preg_replace($pattern, $replacement, $sDocName); | 673 | $sName = preg_replace($pattern, $replacement, $sDocName); |
| 674 | }else{ | 674 | }else{ |
| 675 | $sName = $sDocName.' (2)'; | 675 | $sName = $sDocName.' (2)'; |
| 676 | } | 676 | } |
| 677 | - | 677 | + |
| 678 | return $sName; | 678 | return $sName; |
| 679 | } | 679 | } |
| 680 | - | 680 | + |
| 681 | // {{{ fileExists | 681 | // {{{ fileExists |
| 682 | function fileExists($oFolder, $sFilename) { | 682 | function fileExists($oFolder, $sFilename) { |
| 683 | return Document::fileExists($sFilename, $oFolder->getID()); | 683 | return Document::fileExists($sFilename, $oFolder->getID()); |
| @@ -939,7 +939,7 @@ class KTDocumentUtil { | @@ -939,7 +939,7 @@ class KTDocumentUtil { | ||
| 939 | } | 939 | } |
| 940 | 940 | ||
| 941 | 941 | ||
| 942 | - function copy($oDocument, $oDestinationFolder, $sReason = null) { | 942 | + function copy($oDocument, $oDestinationFolder, $sReason = null, $sDestinationDocName = null) { |
| 943 | // 1. generate a new triad of content, metadata and core objects. | 943 | // 1. generate a new triad of content, metadata and core objects. |
| 944 | // 2. update the storage path. | 944 | // 2. update the storage path. |
| 945 | //print '--------------------------------- BEFORE'; | 945 | //print '--------------------------------- BEFORE'; |
| @@ -958,23 +958,36 @@ class KTDocumentUtil { | @@ -958,23 +958,36 @@ class KTDocumentUtil { | ||
| 958 | // we still have a bogus md_version, but integrity holds, so fix it now. | 958 | // we still have a bogus md_version, but integrity holds, so fix it now. |
| 959 | $oCore = KTDocumentCore::get($id); | 959 | $oCore = KTDocumentCore::get($id); |
| 960 | 960 | ||
| 961 | + // Get the metadata version for the source document | ||
| 961 | $sTable = KTUtil::getTableName('document_metadata_version'); | 962 | $sTable = KTUtil::getTableName('document_metadata_version'); |
| 962 | $sQuery = 'SELECT * FROM ' . $sTable . ' WHERE id = ?'; | 963 | $sQuery = 'SELECT * FROM ' . $sTable . ' WHERE id = ?'; |
| 963 | $aParams = array($oDocument->getMetadataVersionId()); | 964 | $aParams = array($oDocument->getMetadataVersionId()); |
| 964 | $aMDRow = DBUtil::getOneResult(array($sQuery, $aParams)); | 965 | $aMDRow = DBUtil::getOneResult(array($sQuery, $aParams)); |
| 965 | unset($aMDRow['id']); | 966 | unset($aMDRow['id']); |
| 967 | + | ||
| 968 | + // Copy the source metadata into the destination document | ||
| 966 | $aMDRow['document_id'] = $oCore->getId(); | 969 | $aMDRow['document_id'] = $oCore->getId(); |
| 970 | + if(!empty($sDestinationDocName)){ | ||
| 971 | + $aMDRow['name'] = $sDestinationDocName; | ||
| 972 | + $aMDRow['description'] = $sDestinationDocName; | ||
| 973 | + } | ||
| 967 | $id = DBUtil::autoInsert($sTable, $aMDRow); | 974 | $id = DBUtil::autoInsert($sTable, $aMDRow); |
| 968 | if (PEAR::isError($id)) { return $id; } | 975 | if (PEAR::isError($id)) { return $id; } |
| 969 | $oCore->setMetadataVersionId($id); | 976 | $oCore->setMetadataVersionId($id); |
| 970 | $oMDV = KTDocumentMetadataVersion::get($id); | 977 | $oMDV = KTDocumentMetadataVersion::get($id); |
| 971 | 978 | ||
| 979 | + // Get the content version for the source document | ||
| 972 | $sTable = KTUtil::getTableName('document_content_version'); | 980 | $sTable = KTUtil::getTableName('document_content_version'); |
| 973 | $sQuery = 'SELECT * FROM ' . $sTable . ' WHERE id = ?'; | 981 | $sQuery = 'SELECT * FROM ' . $sTable . ' WHERE id = ?'; |
| 974 | $aParams = array($oDocument->_oDocumentContentVersion->getId()); | 982 | $aParams = array($oDocument->_oDocumentContentVersion->getId()); |
| 975 | $aContentRow = DBUtil::getOneResult(array($sQuery, $aParams)); | 983 | $aContentRow = DBUtil::getOneResult(array($sQuery, $aParams)); |
| 976 | unset($aContentRow['id']); | 984 | unset($aContentRow['id']); |
| 985 | + | ||
| 986 | + // Copy the source content into the destination document | ||
| 977 | $aContentRow['document_id'] = $oCore->getId(); | 987 | $aContentRow['document_id'] = $oCore->getId(); |
| 988 | + if(!empty($sDestinationDocName)){ | ||
| 989 | + $aContentRow['filename'] = $sDestinationDocName; | ||
| 990 | + } | ||
| 978 | $id = DBUtil::autoInsert($sTable, $aContentRow); | 991 | $id = DBUtil::autoInsert($sTable, $aContentRow); |
| 979 | if (PEAR::isError($id)) { return $id; } | 992 | if (PEAR::isError($id)) { return $id; } |
| 980 | $oMDV->setContentVersionId($id); | 993 | $oMDV->setContentVersionId($id); |
| @@ -996,6 +1009,7 @@ class KTDocumentUtil { | @@ -996,6 +1009,7 @@ class KTDocumentUtil { | ||
| 996 | $res = KTDocumentUtil::copyMetadata($oNewDocument, $oDocument->getMetadataVersionId()); | 1009 | $res = KTDocumentUtil::copyMetadata($oNewDocument, $oDocument->getMetadataVersionId()); |
| 997 | if (PEAR::isError($res)) { return $res; } | 1010 | if (PEAR::isError($res)) { return $res; } |
| 998 | 1011 | ||
| 1012 | + // Ensure the copied document is not checked out | ||
| 999 | $oNewDocument->setIsCheckedOut(false); | 1013 | $oNewDocument->setIsCheckedOut(false); |
| 1000 | $oNewDocument->setCheckedOutUserID(-1); | 1014 | $oNewDocument->setCheckedOutUserID(-1); |
| 1001 | 1015 |
lib/foldermanagement/folderutil.inc.php
| @@ -7,32 +7,32 @@ | @@ -7,32 +7,32 @@ | ||
| 7 | * KnowledgeTree Open Source Edition | 7 | * KnowledgeTree Open Source Edition |
| 8 | * Document Management Made Simple | 8 | * Document Management Made Simple |
| 9 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited | 9 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited |
| 10 | - * | 10 | + * |
| 11 | * This program is free software; you can redistribute it and/or modify it under | 11 | * This program is free software; you can redistribute it and/or modify it under |
| 12 | * the terms of the GNU General Public License version 3 as published by the | 12 | * the terms of the GNU General Public License version 3 as published by the |
| 13 | * Free Software Foundation. | 13 | * Free Software Foundation. |
| 14 | - * | 14 | + * |
| 15 | * This program is distributed in the hope that it will be useful, but WITHOUT | 15 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 16 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 16 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 17 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | 17 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 18 | * details. | 18 | * details. |
| 19 | - * | 19 | + * |
| 20 | * You should have received a copy of the GNU General Public License | 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 21 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 22 | - * | 22 | + * |
| 23 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, | 23 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, |
| 24 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. | 24 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. |
| 25 | - * | 25 | + * |
| 26 | * The interactive user interfaces in modified source and object code versions | 26 | * The interactive user interfaces in modified source and object code versions |
| 27 | * of this program must display Appropriate Legal Notices, as required under | 27 | * of this program must display Appropriate Legal Notices, as required under |
| 28 | * Section 5 of the GNU General Public License version 3. | 28 | * Section 5 of the GNU General Public License version 3. |
| 29 | - * | 29 | + * |
| 30 | * In accordance with Section 7(b) of the GNU General Public License version 3, | 30 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 31 | * these Appropriate Legal Notices must retain the display of the "Powered by | 31 | * these Appropriate Legal Notices must retain the display of the "Powered by |
| 32 | - * KnowledgeTree" logo and retain the original copyright notice. If the display of the | 32 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the |
| 33 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | 33 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices |
| 34 | - * must display the words "Powered by KnowledgeTree" and retain the original | ||
| 35 | - * copyright notice. | 34 | + * must display the words "Powered by KnowledgeTree" and retain the original |
| 35 | + * copyright notice. | ||
| 36 | * Contributor( s): ______________________________________ | 36 | * Contributor( s): ______________________________________ |
| 37 | */ | 37 | */ |
| 38 | 38 | ||
| @@ -414,8 +414,9 @@ class KTFolderUtil { | @@ -414,8 +414,9 @@ class KTFolderUtil { | ||
| 414 | return true; | 414 | return true; |
| 415 | } | 415 | } |
| 416 | 416 | ||
| 417 | - function copy($oSrcFolder, $oDestFolder, $oUser, $sReason) { | ||
| 418 | - if (KTFolderUtil::exists($oDestFolder, $oSrcFolder->getName())) { | 417 | + function copy($oSrcFolder, $oDestFolder, $oUser, $sReason, $sDestFolderName = NULL, $copyAll = true) { |
| 418 | + $sDestFolderName = (empty($sDestFolderName)) ? $oSrcFolder->getName() : $sDestFolderName; | ||
| 419 | + if (KTFolderUtil::exists($oDestFolder, $sDestFolderName)) { | ||
| 419 | return PEAR::raiseError(_kt("Folder with the same name already exists in the new parent folder")); | 420 | return PEAR::raiseError(_kt("Folder with the same name already exists in the new parent folder")); |
| 420 | } | 421 | } |
| 421 | // | 422 | // |
| @@ -437,7 +438,7 @@ class KTFolderUtil { | @@ -437,7 +438,7 @@ class KTFolderUtil { | ||
| 437 | 438 | ||
| 438 | DBUtil::startTransaction(); | 439 | DBUtil::startTransaction(); |
| 439 | 440 | ||
| 440 | - while (!empty($aRemainingFolders)) { | 441 | + while (!empty($aRemainingFolders) && $copyAll) { |
| 441 | $iFolderId = array_pop($aRemainingFolders); | 442 | $iFolderId = array_pop($aRemainingFolders); |
| 442 | $oFolder = Folder::get($iFolderId); | 443 | $oFolder = Folder::get($iFolderId); |
| 443 | if (PEAR::isError($oFolder) || ($oFolder == false)) { | 444 | if (PEAR::isError($oFolder) || ($oFolder == false)) { |
| @@ -487,15 +488,18 @@ class KTFolderUtil { | @@ -487,15 +488,18 @@ class KTFolderUtil { | ||
| 487 | 488 | ||
| 488 | $aFolderMap = array(); | 489 | $aFolderMap = array(); |
| 489 | 490 | ||
| 490 | - $sTable = KTUtil::getTableName('folders'); | 491 | + $sTable = 'folders'; |
| 491 | $sGetQuery = 'SELECT * FROM ' . $sTable . ' WHERE id = ? '; | 492 | $sGetQuery = 'SELECT * FROM ' . $sTable . ' WHERE id = ? '; |
| 492 | $aParams = array($oSrcFolder->getId()); | 493 | $aParams = array($oSrcFolder->getId()); |
| 493 | $aRow = DBUtil::getOneResult(array($sGetQuery, $aParams)); | 494 | $aRow = DBUtil::getOneResult(array($sGetQuery, $aParams)); |
| 494 | unset($aRow['id']); | 495 | unset($aRow['id']); |
| 496 | + | ||
| 497 | + $aRow['name'] = $sDestFolderName; | ||
| 498 | + $aRow['description'] = $sDestFolderName; | ||
| 495 | $aRow['parent_id'] = $oDestFolder->getId(); | 499 | $aRow['parent_id'] = $oDestFolder->getId(); |
| 496 | $aRow['parent_folder_ids'] = sprintf('%s,%s', $oDestFolder->getParentFolderIDs(), $oDestFolder->getId()); | 500 | $aRow['parent_folder_ids'] = sprintf('%s,%s', $oDestFolder->getParentFolderIDs(), $oDestFolder->getId()); |
| 497 | $aRow['full_path'] = sprintf('%s/%s', $oDestFolder->getFullPath(), $oDestFolder->getName()); | 501 | $aRow['full_path'] = sprintf('%s/%s', $oDestFolder->getFullPath(), $oDestFolder->getName()); |
| 498 | - | 502 | + |
| 499 | $id = DBUtil::autoInsert($sTable, $aRow); | 503 | $id = DBUtil::autoInsert($sTable, $aRow); |
| 500 | if (PEAR::isError($id)) { | 504 | if (PEAR::isError($id)) { |
| 501 | DBUtil::rollback(); | 505 | DBUtil::rollback(); |
| @@ -506,7 +510,7 @@ class KTFolderUtil { | @@ -506,7 +510,7 @@ class KTFolderUtil { | ||
| 506 | $aFolderMap[$sSrcFolderId]['parent_folder_ids'] = $aRow['parent_folder_ids']; | 510 | $aFolderMap[$sSrcFolderId]['parent_folder_ids'] = $aRow['parent_folder_ids']; |
| 507 | $aFolderMap[$sSrcFolderId]['full_path'] = $aRow['full_path']; | 511 | $aFolderMap[$sSrcFolderId]['full_path'] = $aRow['full_path']; |
| 508 | $aFolderMap[$sSrcFolderId]['name'] = $aRow['name']; | 512 | $aFolderMap[$sSrcFolderId]['name'] = $aRow['name']; |
| 509 | - | 513 | + |
| 510 | $oNewBaseFolder = Folder::get($id); | 514 | $oNewBaseFolder = Folder::get($id); |
| 511 | $res = $oStorage->createFolder($oNewBaseFolder); | 515 | $res = $oStorage->createFolder($oNewBaseFolder); |
| 512 | if (PEAR::isError($res)) { | 516 | if (PEAR::isError($res)) { |
| @@ -517,12 +521,13 @@ class KTFolderUtil { | @@ -517,12 +521,13 @@ class KTFolderUtil { | ||
| 517 | $aRemainingFolders = Folder::getList(array('parent_id = ?', array($oSrcFolder->getId())), array('ids' => true)); | 521 | $aRemainingFolders = Folder::getList(array('parent_id = ?', array($oSrcFolder->getId())), array('ids' => true)); |
| 518 | 522 | ||
| 519 | 523 | ||
| 520 | - while (!empty($aRemainingFolders)) { | 524 | + while (!empty($aRemainingFolders) && $copyAll) { |
| 521 | $iFolderId = array_pop($aRemainingFolders); | 525 | $iFolderId = array_pop($aRemainingFolders); |
| 522 | 526 | ||
| 523 | $aParams = array($iFolderId); | 527 | $aParams = array($iFolderId); |
| 524 | $aRow = DBUtil::getOneResult(array($sGetQuery, $aParams)); | 528 | $aRow = DBUtil::getOneResult(array($sGetQuery, $aParams)); |
| 525 | unset($aRow['id']); | 529 | unset($aRow['id']); |
| 530 | + | ||
| 526 | // since we are nested, we will have solved the parent first. | 531 | // since we are nested, we will have solved the parent first. |
| 527 | $sPrevParentId = $aRow['parent_id']; | 532 | $sPrevParentId = $aRow['parent_id']; |
| 528 | $aRow['parent_id'] = $aFolderMap[$aRow['parent_id']]['parent_id']; | 533 | $aRow['parent_id'] = $aFolderMap[$aRow['parent_id']]['parent_id']; |
| @@ -552,7 +557,7 @@ class KTFolderUtil { | @@ -552,7 +557,7 @@ class KTFolderUtil { | ||
| 552 | $aCFIds = Folder::getList(array('parent_id = ?', array($iFolderId)), array('ids' => true)); | 557 | $aCFIds = Folder::getList(array('parent_id = ?', array($iFolderId)), array('ids' => true)); |
| 553 | $aRemainingFolders = kt_array_merge($aRemainingFolders, $aCFIds); | 558 | $aRemainingFolders = kt_array_merge($aRemainingFolders, $aCFIds); |
| 554 | } | 559 | } |
| 555 | - | 560 | + |
| 556 | // now we can go ahead. | 561 | // now we can go ahead. |
| 557 | foreach ($aDocuments as $oDocument) { | 562 | foreach ($aDocuments as $oDocument) { |
| 558 | $oChildDestinationFolder = Folder::get($aFolderMap[$oDocument->getFolderID()]['parent_id']); | 563 | $oChildDestinationFolder = Folder::get($aFolderMap[$oDocument->getFolderID()]['parent_id']); |
lib/permissions/permissionutil.inc.php
| @@ -5,32 +5,32 @@ | @@ -5,32 +5,32 @@ | ||
| 5 | * KnowledgeTree Open Source Edition | 5 | * KnowledgeTree Open Source Edition |
| 6 | * Document Management Made Simple | 6 | * Document Management Made Simple |
| 7 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited | 7 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited |
| 8 | - * | 8 | + * |
| 9 | * This program is free software; you can redistribute it and/or modify it under | 9 | * This program is free software; you can redistribute it and/or modify it under |
| 10 | * the terms of the GNU General Public License version 3 as published by the | 10 | * the terms of the GNU General Public License version 3 as published by the |
| 11 | * Free Software Foundation. | 11 | * Free Software Foundation. |
| 12 | - * | 12 | + * |
| 13 | * This program is distributed in the hope that it will be useful, but WITHOUT | 13 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | 15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 16 | * details. | 16 | * details. |
| 17 | - * | 17 | + * |
| 18 | * You should have received a copy of the GNU General Public License | 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | - * | 20 | + * |
| 21 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, | 21 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, |
| 22 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. | 22 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. |
| 23 | - * | 23 | + * |
| 24 | * The interactive user interfaces in modified source and object code versions | 24 | * The interactive user interfaces in modified source and object code versions |
| 25 | * of this program must display Appropriate Legal Notices, as required under | 25 | * of this program must display Appropriate Legal Notices, as required under |
| 26 | * Section 5 of the GNU General Public License version 3. | 26 | * Section 5 of the GNU General Public License version 3. |
| 27 | - * | 27 | + * |
| 28 | * In accordance with Section 7(b) of the GNU General Public License version 3, | 28 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 29 | * these Appropriate Legal Notices must retain the display of the "Powered by | 29 | * these Appropriate Legal Notices must retain the display of the "Powered by |
| 30 | - * KnowledgeTree" logo and retain the original copyright notice. If the display of the | 30 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the |
| 31 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | 31 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices |
| 32 | - * must display the words "Powered by KnowledgeTree" and retain the original | ||
| 33 | - * copyright notice. | 32 | + * must display the words "Powered by KnowledgeTree" and retain the original |
| 33 | + * copyright notice. | ||
| 34 | * Contributor( s): ______________________________________ | 34 | * Contributor( s): ______________________________________ |
| 35 | * | 35 | * |
| 36 | */ | 36 | */ |
| @@ -52,6 +52,9 @@ require_once(KT_LIB_DIR . "/workflow/workflowutil.inc.php"); | @@ -52,6 +52,9 @@ require_once(KT_LIB_DIR . "/workflow/workflowutil.inc.php"); | ||
| 52 | require_once(KT_LIB_DIR . "/workflow/workflowstatepermissionsassignment.inc.php"); | 52 | require_once(KT_LIB_DIR . "/workflow/workflowstatepermissionsassignment.inc.php"); |
| 53 | 53 | ||
| 54 | class KTPermissionUtil { | 54 | class KTPermissionUtil { |
| 55 | + | ||
| 56 | + static $permArr = array(); | ||
| 57 | + | ||
| 55 | // {{{ generateDescriptor | 58 | // {{{ generateDescriptor |
| 56 | /** | 59 | /** |
| 57 | * Generate a unique textual representation of a specific collection | 60 | * Generate a unique textual representation of a specific collection |
| @@ -93,7 +96,7 @@ class KTPermissionUtil { | @@ -93,7 +96,7 @@ class KTPermissionUtil { | ||
| 93 | $oDescriptor =& KTPermissionDescriptor::getByDescriptor(md5($sDescriptor)); | 96 | $oDescriptor =& KTPermissionDescriptor::getByDescriptor(md5($sDescriptor)); |
| 94 | if (PEAR::isError($oDescriptor)) { | 97 | if (PEAR::isError($oDescriptor)) { |
| 95 | $oOriginalDescriptor = $oDescriptor; | 98 | $oOriginalDescriptor = $oDescriptor; |
| 96 | - | 99 | + |
| 97 | $oDescriptor =& KTPermissionDescriptor::createFromArray(array( | 100 | $oDescriptor =& KTPermissionDescriptor::createFromArray(array( |
| 98 | "descriptortext" => $sDescriptor, | 101 | "descriptortext" => $sDescriptor, |
| 99 | )); | 102 | )); |
| @@ -112,7 +115,7 @@ class KTPermissionUtil { | @@ -112,7 +115,7 @@ class KTPermissionUtil { | ||
| 112 | exit(0); | 115 | exit(0); |
| 113 | } | 116 | } |
| 114 | $oDescriptor->saveAllowed($aAllowed); | 117 | $oDescriptor->saveAllowed($aAllowed); |
| 115 | - | 118 | + |
| 116 | } | 119 | } |
| 117 | return $oDescriptor; | 120 | return $oDescriptor; |
| 118 | } | 121 | } |
| @@ -193,7 +196,7 @@ class KTPermissionUtil { | @@ -193,7 +196,7 @@ class KTPermissionUtil { | ||
| 193 | $sWhere = 'permission_object_id = ?'; | 196 | $sWhere = 'permission_object_id = ?'; |
| 194 | $aParams = array($oPO->getID()); | 197 | $aParams = array($oPO->getID()); |
| 195 | $aFolders =& Folder::getList(array($sWhere, $aParams)); | 198 | $aFolders =& Folder::getList(array($sWhere, $aParams)); |
| 196 | - if (!PEAR::isError($aFolders)) { | 199 | + if (!PEAR::isError($aFolders)) { |
| 197 | foreach ($aFolders as $oFolder) { | 200 | foreach ($aFolders as $oFolder) { |
| 198 | KTPermissionUtil::updatePermissionLookup($oFolder); | 201 | KTPermissionUtil::updatePermissionLookup($oFolder); |
| 199 | } | 202 | } |
| @@ -253,7 +256,7 @@ class KTPermissionUtil { | @@ -253,7 +256,7 @@ class KTPermissionUtil { | ||
| 253 | } | 256 | } |
| 254 | } | 257 | } |
| 255 | } | 258 | } |
| 256 | - | 259 | + |
| 257 | $oChannel =& KTPermissionChannel::getSingleton(); | 260 | $oChannel =& KTPermissionChannel::getSingleton(); |
| 258 | if (is_a($oFolderOrDocument, 'Folder')) { | 261 | if (is_a($oFolderOrDocument, 'Folder')) { |
| 259 | $msg = sprintf("Updating folder %s", join("/", $oFolderOrDocument->getPathArray())); | 262 | $msg = sprintf("Updating folder %s", join("/", $oFolderOrDocument->getPathArray())); |
| @@ -265,7 +268,7 @@ class KTPermissionUtil { | @@ -265,7 +268,7 @@ class KTPermissionUtil { | ||
| 265 | } | 268 | } |
| 266 | } | 269 | } |
| 267 | $oChannel->sendMessage(new KTPermissionGenericMessage($msg)); | 270 | $oChannel->sendMessage(new KTPermissionGenericMessage($msg)); |
| 268 | - //var_dump($msg); | 271 | + //var_dump($msg); |
| 269 | $iPermissionObjectId = $oFolderOrDocument->getPermissionObjectID(); | 272 | $iPermissionObjectId = $oFolderOrDocument->getPermissionObjectID(); |
| 270 | if (empty($iPermissionObjectId)) { | 273 | if (empty($iPermissionObjectId)) { |
| 271 | return; | 274 | return; |
| @@ -311,7 +314,7 @@ class KTPermissionUtil { | @@ -311,7 +314,7 @@ class KTPermissionUtil { | ||
| 311 | foreach ($aWorkflowStatePermissionAssignments as $oAssignment) { | 314 | foreach ($aWorkflowStatePermissionAssignments as $oAssignment) { |
| 312 | $iPermissionId = $oAssignment->getPermissionId(); | 315 | $iPermissionId = $oAssignment->getPermissionId(); |
| 313 | $iPermissionDescriptorId = $oAssignment->getDescriptorId(); | 316 | $iPermissionDescriptorId = $oAssignment->getDescriptorId(); |
| 314 | - | 317 | + |
| 315 | $oPD = KTPermissionDescriptor::get($iPermissionDescriptorId); | 318 | $oPD = KTPermissionDescriptor::get($iPermissionDescriptorId); |
| 316 | $aGroupIDs = $oPD->getGroups(); | 319 | $aGroupIDs = $oPD->getGroups(); |
| 317 | $aUserIDs = array(); | 320 | $aUserIDs = array(); |
| @@ -330,16 +333,16 @@ class KTPermissionUtil { | @@ -330,16 +333,16 @@ class KTPermissionUtil { | ||
| 330 | $iRoleSourceFolder = null; | 333 | $iRoleSourceFolder = null; |
| 331 | if (is_a($oFolderOrDocument, 'KTDocumentCore') || is_a($oFolderOrDocument, 'Document')) { $iRoleSourceFolder = $oFolderOrDocument->getFolderID(); } | 334 | if (is_a($oFolderOrDocument, 'KTDocumentCore') || is_a($oFolderOrDocument, 'Document')) { $iRoleSourceFolder = $oFolderOrDocument->getFolderID(); } |
| 332 | else { $iRoleSourceFolder = $oFolderOrDocument->getId(); } | 335 | else { $iRoleSourceFolder = $oFolderOrDocument->getId(); } |
| 333 | - | 336 | + |
| 334 | // very minor perf win: map role_id (in context) to PD. | 337 | // very minor perf win: map role_id (in context) to PD. |
| 335 | - $_roleCache = array(); | ||
| 336 | - | 338 | + $_roleCache = array(); |
| 339 | + | ||
| 337 | foreach ($aMapPermAllowed as $iPermissionId => $aAllowed) { | 340 | foreach ($aMapPermAllowed as $iPermissionId => $aAllowed) { |
| 338 | $aAfterRoles = array(); | 341 | $aAfterRoles = array(); |
| 339 | if (array_key_exists('role', $aAllowed)) { | 342 | if (array_key_exists('role', $aAllowed)) { |
| 340 | foreach ($aAllowed['role'] as $k => $iRoleId) { | 343 | foreach ($aAllowed['role'] as $k => $iRoleId) { |
| 341 | // store the PD <-> RoleId map | 344 | // store the PD <-> RoleId map |
| 342 | - | 345 | + |
| 343 | // special-case "all" or "authenticated". | 346 | // special-case "all" or "authenticated". |
| 344 | if (($iRoleId == -3) || ($iRoleId == -4)) { | 347 | if (($iRoleId == -3) || ($iRoleId == -4)) { |
| 345 | $aAfterRoles[] = $iRoleId; | 348 | $aAfterRoles[] = $iRoleId; |
| @@ -366,15 +369,15 @@ class KTPermissionUtil { | @@ -366,15 +369,15 @@ class KTPermissionUtil { | ||
| 366 | 369 | ||
| 367 | unset($aAllowed['role'][$k]); | 370 | unset($aAllowed['role'][$k]); |
| 368 | } | 371 | } |
| 369 | - | 372 | + |
| 370 | } | 373 | } |
| 371 | 374 | ||
| 372 | - unset($aMapPermAllowed[$iPermissionId]['role']); | ||
| 373 | - if (!empty($aAfterRoles)) { | 375 | + unset($aMapPermAllowed[$iPermissionId]['role']); |
| 376 | + if (!empty($aAfterRoles)) { | ||
| 374 | $aMapPermAllowed[$iPermissionId]['role'] = $aAfterRoles; | 377 | $aMapPermAllowed[$iPermissionId]['role'] = $aAfterRoles; |
| 375 | } | 378 | } |
| 376 | } | 379 | } |
| 377 | - | 380 | + |
| 378 | /* | 381 | /* |
| 379 | print '<pre>'; | 382 | print '<pre>'; |
| 380 | print '=======' . $oFolderOrDocument->getName(); | 383 | print '=======' . $oFolderOrDocument->getName(); |
| @@ -382,7 +385,7 @@ class KTPermissionUtil { | @@ -382,7 +385,7 @@ class KTPermissionUtil { | ||
| 382 | var_dump($aMapPermAllowed); | 385 | var_dump($aMapPermAllowed); |
| 383 | print '</pre>'; | 386 | print '</pre>'; |
| 384 | */ | 387 | */ |
| 385 | - | 388 | + |
| 386 | 389 | ||
| 387 | $aMapPermDesc = array(); | 390 | $aMapPermDesc = array(); |
| 388 | foreach ($aMapPermAllowed as $iPermissionId => $aAllowed) { | 391 | foreach ($aMapPermAllowed as $iPermissionId => $aAllowed) { |
| @@ -404,6 +407,7 @@ class KTPermissionUtil { | @@ -404,6 +407,7 @@ class KTPermissionUtil { | ||
| 404 | * and so forth. | 407 | * and so forth. |
| 405 | */ | 408 | */ |
| 406 | function userHasPermissionOnItem($oUser, $oPermission, $oFolderOrDocument) { | 409 | function userHasPermissionOnItem($oUser, $oPermission, $oFolderOrDocument) { |
| 410 | + | ||
| 407 | if (is_string($oPermission)) { | 411 | if (is_string($oPermission)) { |
| 408 | $oPermission =& KTPermission::getByName($oPermission); | 412 | $oPermission =& KTPermission::getByName($oPermission); |
| 409 | } | 413 | } |
| @@ -413,20 +417,44 @@ class KTPermissionUtil { | @@ -413,20 +417,44 @@ class KTPermissionUtil { | ||
| 413 | if (PEAR::isError($oFolderOrDocument) || $oFolderOrDocument == null) { | 417 | if (PEAR::isError($oFolderOrDocument) || $oFolderOrDocument == null) { |
| 414 | return false; | 418 | return false; |
| 415 | } | 419 | } |
| 420 | + | ||
| 421 | + // Quick fix for multiple permissions look ups. | ||
| 422 | + // For the current lookup, if the permissions have been checked then return their value | ||
| 423 | + $iPermId = $oPermission->getID(); | ||
| 424 | + $iDocId = $oFolderOrDocument->getID(); | ||
| 425 | + $lookup = 'folders'; | ||
| 426 | + if(is_a($oEntity, 'Document') || is_a($oEntity, 'DocumentProxy')){ | ||
| 427 | + $lookup = 'docs'; | ||
| 428 | + } | ||
| 429 | + // check if permission has been set | ||
| 430 | + // $permArr[permId] = array('folders' => array('id' => bool), 'docs' => array('id' => bool)); | ||
| 431 | + if(isset($permArr[$iPermId][$lookup][$iDocId])){ | ||
| 432 | + return $permArr[$iPermId][$lookup][$iDocId]; | ||
| 433 | + } | ||
| 434 | + | ||
| 435 | + | ||
| 436 | + | ||
| 416 | $oPL = KTPermissionLookup::get($oFolderOrDocument->getPermissionLookupID()); | 437 | $oPL = KTPermissionLookup::get($oFolderOrDocument->getPermissionLookupID()); |
| 417 | $oPLA = KTPermissionLookupAssignment::getByPermissionAndLookup($oPermission, $oPL); | 438 | $oPLA = KTPermissionLookupAssignment::getByPermissionAndLookup($oPermission, $oPL); |
| 418 | if (PEAR::isError($oPLA)) { | 439 | if (PEAR::isError($oPLA)) { |
| 419 | //print $oPL->getID(); | 440 | //print $oPL->getID(); |
| 441 | + $permArr[$iPermId][$lookup][$iDocId] = false; | ||
| 420 | return false; | 442 | return false; |
| 421 | } | 443 | } |
| 422 | $oPD = KTPermissionDescriptor::get($oPLA->getPermissionDescriptorID()); | 444 | $oPD = KTPermissionDescriptor::get($oPLA->getPermissionDescriptorID()); |
| 423 | - | 445 | + |
| 446 | + // set permission array to true | ||
| 447 | + $permArr[$iPermId][$lookup][$iDocId] = true; | ||
| 448 | + | ||
| 449 | + // check for permissions | ||
| 424 | $aGroups = GroupUtil::listGroupsForUserExpand($oUser); | 450 | $aGroups = GroupUtil::listGroupsForUserExpand($oUser); |
| 425 | if ($oPD->hasRoles(array(-3))) { return true; } // everyone has access. | 451 | if ($oPD->hasRoles(array(-3))) { return true; } // everyone has access. |
| 426 | else if ($oPD->hasUsers(array($oUser))) { return true; } | 452 | else if ($oPD->hasUsers(array($oUser))) { return true; } |
| 427 | else if ($oPD->hasGroups($aGroups)) { return true; } | 453 | else if ($oPD->hasGroups($aGroups)) { return true; } |
| 428 | else if ($oPD->hasRoles(array(-4)) && !$oUser->isAnonymous()) { return true; } | 454 | else if ($oPD->hasRoles(array(-4)) && !$oUser->isAnonymous()) { return true; } |
| 429 | - | 455 | + |
| 456 | + // permission isn't true, set to false | ||
| 457 | + $permArr[$iPermId][$lookup][$iDocId] = false; | ||
| 430 | return false; | 458 | return false; |
| 431 | } | 459 | } |
| 432 | // }}} | 460 | // }}} |
| @@ -496,7 +524,7 @@ class KTPermissionUtil { | @@ -496,7 +524,7 @@ class KTPermissionUtil { | ||
| 496 | 'groupid' => $oOrigDC->getGroupId(), | 524 | 'groupid' => $oOrigDC->getGroupId(), |
| 497 | 'conditionid' => $oOrigDC->getConditionId(), | 525 | 'conditionid' => $oOrigDC->getConditionId(), |
| 498 | )); | 526 | )); |
| 499 | - | 527 | + |
| 500 | $oNewDC->saveAssignment($oOrigDC->getAssignment()); | 528 | $oNewDC->saveAssignment($oOrigDC->getAssignment()); |
| 501 | } | 529 | } |
| 502 | 530 | ||
| @@ -582,7 +610,7 @@ class KTPermissionUtil { | @@ -582,7 +610,7 @@ class KTPermissionUtil { | ||
| 582 | $iNewPOID = $oFolder->getPermissionObjectID(); | 610 | $iNewPOID = $oFolder->getPermissionObjectID(); |
| 583 | $oNewPO =& KTPermissionObject::get($iNewPOID); | 611 | $oNewPO =& KTPermissionObject::get($iNewPOID); |
| 584 | 612 | ||
| 585 | - | 613 | + |
| 586 | $oDocumentOrFolder->setPermissionObjectID($iNewPOID); | 614 | $oDocumentOrFolder->setPermissionObjectID($iNewPOID); |
| 587 | $oDocumentOrFolder->update(); | 615 | $oDocumentOrFolder->update(); |
| 588 | 616 | ||
| @@ -591,7 +619,7 @@ class KTPermissionUtil { | @@ -591,7 +619,7 @@ class KTPermissionUtil { | ||
| 591 | KTPermissionUtil::updatePermissionLookup($oDocumentOrFolder); | 619 | KTPermissionUtil::updatePermissionLookup($oDocumentOrFolder); |
| 592 | return; | 620 | return; |
| 593 | } | 621 | } |
| 594 | - | 622 | + |
| 595 | $iFolderID = $oDocumentOrFolder->getID(); | 623 | $iFolderID = $oDocumentOrFolder->getID(); |
| 596 | $sFolderIDs = Folder::generateFolderIDs($iFolderID); | 624 | $sFolderIDs = Folder::generateFolderIDs($iFolderID); |
| 597 | $sFolderIDs .= '%'; | 625 | $sFolderIDs .= '%'; |
lib/session/Session.inc
| @@ -196,7 +196,7 @@ class Session { | @@ -196,7 +196,7 @@ class Session { | ||
| 196 | 196 | ||
| 197 | if ($default->systemVersion != $version) { | 197 | if ($default->systemVersion != $version) { |
| 198 | if (KTLOG_CACHE) $default->log->info("Session::verify : Database not upgraded"); | 198 | if (KTLOG_CACHE) $default->log->info("Session::verify : Database not upgraded"); |
| 199 | - return PEAR::raiseError(sprintf(_kt('Incompatible database version (%s, expected version %s) - contact the administrator'), $version, $default->systemVersion)); | 199 | + return PEAR::raiseError(sprintf(_kt('Database incompatibility error: <br> Please ensure that you have completed the database upgrade procedure. <br> Please <a href=%s>click here</a> to complete.'),'setup/upgrade.php' )); |
| 200 | } | 200 | } |
| 201 | 201 | ||
| 202 | if (empty($sessionID)) { | 202 | if (empty($sessionID)) { |
lib/util/ktutil.inc
| @@ -175,10 +175,10 @@ class KTUtil { | @@ -175,10 +175,10 @@ class KTUtil { | ||
| 175 | } | 175 | } |
| 176 | 176 | ||
| 177 | //this function fudges the strlen. It returns a ? when the character is a multi-byte character. | 177 | //this function fudges the strlen. It returns a ? when the character is a multi-byte character. |
| 178 | - //str len is therefore measured correctly. | 178 | + //str len is therefore measured correctly by counting the ?'s. |
| 179 | //http://www.phpwact.org/php/i18n/charsets | 179 | //http://www.phpwact.org/php/i18n/charsets |
| 180 | function utf8_strlen($string){ | 180 | function utf8_strlen($string){ |
| 181 | - return strlen(utf8_decode($str)); | 181 | + return strlen(utf8_decode($string)); |
| 182 | } | 182 | } |
| 183 | 183 | ||
| 184 | static function &arrayGet($aArray, $sKey, $mDefault = null, $bDefaultIfEmpty = true) { | 184 | static function &arrayGet($aArray, $sKey, $mDefault = null, $bDefaultIfEmpty = true) { |
lib/workflow/workflowutil.inc.php
| @@ -5,32 +5,32 @@ | @@ -5,32 +5,32 @@ | ||
| 5 | * KnowledgeTree Open Source Edition | 5 | * KnowledgeTree Open Source Edition |
| 6 | * Document Management Made Simple | 6 | * Document Management Made Simple |
| 7 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited | 7 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited |
| 8 | - * | 8 | + * |
| 9 | * This program is free software; you can redistribute it and/or modify it under | 9 | * This program is free software; you can redistribute it and/or modify it under |
| 10 | * the terms of the GNU General Public License version 3 as published by the | 10 | * the terms of the GNU General Public License version 3 as published by the |
| 11 | * Free Software Foundation. | 11 | * Free Software Foundation. |
| 12 | - * | 12 | + * |
| 13 | * This program is distributed in the hope that it will be useful, but WITHOUT | 13 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | 15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 16 | * details. | 16 | * details. |
| 17 | - * | 17 | + * |
| 18 | * You should have received a copy of the GNU General Public License | 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | - * | 20 | + * |
| 21 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, | 21 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, |
| 22 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. | 22 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. |
| 23 | - * | 23 | + * |
| 24 | * The interactive user interfaces in modified source and object code versions | 24 | * The interactive user interfaces in modified source and object code versions |
| 25 | * of this program must display Appropriate Legal Notices, as required under | 25 | * of this program must display Appropriate Legal Notices, as required under |
| 26 | * Section 5 of the GNU General Public License version 3. | 26 | * Section 5 of the GNU General Public License version 3. |
| 27 | - * | 27 | + * |
| 28 | * In accordance with Section 7(b) of the GNU General Public License version 3, | 28 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 29 | * these Appropriate Legal Notices must retain the display of the "Powered by | 29 | * these Appropriate Legal Notices must retain the display of the "Powered by |
| 30 | - * KnowledgeTree" logo and retain the original copyright notice. If the display of the | 30 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the |
| 31 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | 31 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices |
| 32 | - * must display the words "Powered by KnowledgeTree" and retain the original | ||
| 33 | - * copyright notice. | 32 | + * must display the words "Powered by KnowledgeTree" and retain the original |
| 33 | + * copyright notice. | ||
| 34 | * Contributor( s): ______________________________________ | 34 | * Contributor( s): ______________________________________ |
| 35 | * | 35 | * |
| 36 | */ | 36 | */ |
| @@ -837,7 +837,7 @@ class KTWorkflowUtil { | @@ -837,7 +837,7 @@ class KTWorkflowUtil { | ||
| 837 | if (PEAR::isError($res)) { return $res; } | 837 | if (PEAR::isError($res)) { return $res; } |
| 838 | 838 | ||
| 839 | Document::clearAllCaches(); | 839 | Document::clearAllCaches(); |
| 840 | - KTWorkflowTransition::clearAllCaches(); | 840 | + KTWorkflowTransition::clearCachedGroups(); |
| 841 | } | 841 | } |
| 842 | } | 842 | } |
| 843 | 843 |
login.php
| @@ -95,14 +95,24 @@ class LoginPageDispatcher extends KTDispatcher { | @@ -95,14 +95,24 @@ class LoginPageDispatcher extends KTDispatcher { | ||
| 95 | #var_dump($oUser); | 95 | #var_dump($oUser); |
| 96 | #var_dump(PEAR::raiseError()); | 96 | #var_dump(PEAR::raiseError()); |
| 97 | } | 97 | } |
| 98 | + $iOldUserID = checkLastSessionUserID(); | ||
| 99 | + | ||
| 100 | + //if the current person logging in isn't the same person who logged out or timed out | ||
| 101 | + //then set the redirect to the dashboard and not the last page that was viewed. | ||
| 102 | + if ($oUser->getId() != $iOldUserID['user_id']) | ||
| 103 | + { | ||
| 104 | + $_REQUEST['redirect'] = generateControllerLink('dashboard'); | ||
| 105 | + | ||
| 106 | + } | ||
| 107 | + | ||
| 98 | $session = new Session(); | 108 | $session = new Session(); |
| 99 | $sessionID = $session->create($oUser); | 109 | $sessionID = $session->create($oUser); |
| 100 | if (PEAR::isError($sessionID)) { | 110 | if (PEAR::isError($sessionID)) { |
| 101 | return $sessionID; | 111 | return $sessionID; |
| 102 | } | 112 | } |
| 103 | - | ||
| 104 | - $redirect = KTUtil::arrayGet($_REQUEST, 'redirect'); | ||
| 105 | - | 113 | + |
| 114 | + $redirect = KTUtil::arrayGet($_REQUEST, 'redirect'); | ||
| 115 | + | ||
| 106 | // DEPRECATED initialise page-level authorisation array | 116 | // DEPRECATED initialise page-level authorisation array |
| 107 | $_SESSION["pageAccess"] = NULL; | 117 | $_SESSION["pageAccess"] = NULL; |
| 108 | 118 | ||
| @@ -145,6 +155,10 @@ class LoginPageDispatcher extends KTDispatcher { | @@ -145,6 +155,10 @@ class LoginPageDispatcher extends KTDispatcher { | ||
| 145 | header('Content-type: text/html; charset=UTF-8'); | 155 | header('Content-type: text/html; charset=UTF-8'); |
| 146 | 156 | ||
| 147 | $errorMessage = KTUtil::arrayGet($_REQUEST, 'errorMessage'); | 157 | $errorMessage = KTUtil::arrayGet($_REQUEST, 'errorMessage'); |
| 158 | + session_start(); | ||
| 159 | + | ||
| 160 | + $errorMessageConfirm = $_SESSION['errormessage']['login']; | ||
| 161 | + | ||
| 148 | $redirect = KTUtil::arrayGet($_REQUEST, 'redirect'); | 162 | $redirect = KTUtil::arrayGet($_REQUEST, 'redirect'); |
| 149 | 163 | ||
| 150 | $oReg =& KTi18nregistry::getSingleton(); | 164 | $oReg =& KTi18nregistry::getSingleton(); |
| @@ -168,6 +182,7 @@ class LoginPageDispatcher extends KTDispatcher { | @@ -168,6 +182,7 @@ class LoginPageDispatcher extends KTDispatcher { | ||
| 168 | $aTemplateData = array( | 182 | $aTemplateData = array( |
| 169 | "context" => $this, | 183 | "context" => $this, |
| 170 | 'errorMessage' => $errorMessage, | 184 | 'errorMessage' => $errorMessage, |
| 185 | + 'errorMessageConfirm' => $errorMessageConfirm, | ||
| 171 | 'redirect' => $redirect, | 186 | 'redirect' => $redirect, |
| 172 | 'systemVersion' => $default->systemVersion, | 187 | 'systemVersion' => $default->systemVersion, |
| 173 | 'versionName' => $default->versionName, | 188 | 'versionName' => $default->versionName, |
| @@ -322,6 +337,14 @@ class LoginPageDispatcher extends KTDispatcher { | @@ -322,6 +337,14 @@ class LoginPageDispatcher extends KTDispatcher { | ||
| 322 | } | 337 | } |
| 323 | } | 338 | } |
| 324 | 339 | ||
| 340 | +//FIXME Direct Database Access | ||
| 341 | +//checkLastSessionUserID finds the last user to logout or timeout | ||
| 342 | +function checkLastSessionUserID() | ||
| 343 | +{ | ||
| 344 | + $sQuery = 'SELECT user_id FROM user_history ORDER BY id DESC LIMIT 1'; | ||
| 345 | + $res = DBUtil::getOneResult($sQuery); | ||
| 346 | + return $res; | ||
| 347 | +} | ||
| 325 | 348 | ||
| 326 | $dispatcher =& new LoginPageDispatcher(); | 349 | $dispatcher =& new LoginPageDispatcher(); |
| 327 | $dispatcher->dispatch(); | 350 | $dispatcher->dispatch(); |
plugins/housekeeper/HouseKeeperPlugin.php
| @@ -53,7 +53,9 @@ class HouseKeeperPlugin extends KTPlugin | @@ -53,7 +53,9 @@ class HouseKeeperPlugin extends KTPlugin | ||
| 53 | $cacheDir = $config->get('cache/cacheDirectory'); | 53 | $cacheDir = $config->get('cache/cacheDirectory'); |
| 54 | $logDir = $config->get('urls/logDirectory'); | 54 | $logDir = $config->get('urls/logDirectory'); |
| 55 | $docsDir = $config->get('urls/documentRoot'); | 55 | $docsDir = $config->get('urls/documentRoot'); |
| 56 | - $luceneDir = $config->get('indexer/luceneDirectory'); | 56 | + |
| 57 | + $indexer = Indexer::get(); | ||
| 58 | + $luceneDir = $indexer->getIndexDirectory(); | ||
| 57 | 59 | ||
| 58 | $systemDir = OS_UNIX?'/tmp':'c:/windows/temp'; | 60 | $systemDir = OS_UNIX?'/tmp':'c:/windows/temp'; |
| 59 | 61 | ||
| @@ -85,6 +87,8 @@ class HouseKeeperPlugin extends KTPlugin | @@ -85,6 +87,8 @@ class HouseKeeperPlugin extends KTPlugin | ||
| 85 | 'canClean'=>true | 87 | 'canClean'=>true |
| 86 | ); | 88 | ); |
| 87 | 89 | ||
| 90 | + if (is_dir($docsDir)) | ||
| 91 | + { | ||
| 88 | $this->folders[] = | 92 | $this->folders[] = |
| 89 | array( | 93 | array( |
| 90 | 'name'=>_kt('KnowledgeTree Documents'), | 94 | 'name'=>_kt('KnowledgeTree Documents'), |
| @@ -92,6 +96,10 @@ class HouseKeeperPlugin extends KTPlugin | @@ -92,6 +96,10 @@ class HouseKeeperPlugin extends KTPlugin | ||
| 92 | 'pattern'=>'', | 96 | 'pattern'=>'', |
| 93 | 'canClean'=>false | 97 | 'canClean'=>false |
| 94 | ); | 98 | ); |
| 99 | + } | ||
| 100 | + | ||
| 101 | + if (is_dir($luceneDir)) | ||
| 102 | + { | ||
| 95 | $this->folders[] = | 103 | $this->folders[] = |
| 96 | array( | 104 | array( |
| 97 | 'name'=>_kt('KnowledgeTree Document Index'), | 105 | 'name'=>_kt('KnowledgeTree Document Index'), |
| @@ -99,6 +107,7 @@ class HouseKeeperPlugin extends KTPlugin | @@ -99,6 +107,7 @@ class HouseKeeperPlugin extends KTPlugin | ||
| 99 | 'pattern'=>'', | 107 | 'pattern'=>'', |
| 100 | 'canClean'=>false | 108 | 'canClean'=>false |
| 101 | ); | 109 | ); |
| 110 | + } | ||
| 102 | 111 | ||
| 103 | } | 112 | } |
| 104 | 113 |
plugins/ktcore/admin/managePermissions.php
| @@ -44,13 +44,25 @@ require_once(KT_LIB_DIR . "/widgets/fieldWidgets.php"); | @@ -44,13 +44,25 @@ require_once(KT_LIB_DIR . "/widgets/fieldWidgets.php"); | ||
| 44 | class ManagePermissionsDispatcher extends KTAdminDispatcher { | 44 | class ManagePermissionsDispatcher extends KTAdminDispatcher { |
| 45 | var $sHelpPage = 'ktcore/admin/manage permissions.html'; | 45 | var $sHelpPage = 'ktcore/admin/manage permissions.html'; |
| 46 | function do_main() { | 46 | function do_main() { |
| 47 | + session_start(); | ||
| 47 | $this->oPage->setTitle(_kt('Manage Permissions')); | 48 | $this->oPage->setTitle(_kt('Manage Permissions')); |
| 48 | $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('Manage Permissions')); | 49 | $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('Manage Permissions')); |
| 49 | 50 | ||
| 50 | $add_fields = array(); | 51 | $add_fields = array(); |
| 51 | - $add_fields[] = new KTStringWidget(_kt('System Name'), _kt('The internal name used for the permission. This should never be changed.'), 'name', null, $this->oPage, true); | ||
| 52 | - $add_fields[] = new KTStringWidget(_kt('Display Name'), _kt('A short name that is shown to users whenever permissions must be assigned.'), 'human_name', null, $this->oPage, true); | 52 | + $add_fields[] = new KTStringWidget(_kt('System Name'), _kt('The internal name used for the permission. This should never be changed.'), 'name', null, $this->oPage, true, 'name'); |
| 53 | + $add_fields[] = new KTStringWidget(_kt('Display Name'), _kt('A short name that is shown to users whenever permissions must be assigned.'), 'human_name', null, $this->oPage, true, 'human_name'); | ||
| 53 | 54 | ||
| 55 | + if($_SESSION['Permission']['NameValue']) | ||
| 56 | + { | ||
| 57 | + $this->sNameVal = $_SESSION['Permission']['NameValue']; | ||
| 58 | + $_SESSION['Permission']['NameValue'] = ''; | ||
| 59 | + } | ||
| 60 | + else if($_SESSION['Permission']['HumanNameValue']) | ||
| 61 | + { | ||
| 62 | + $this->sHumanNameVal = $_SESSION['Permission']['HumanNameValue']; | ||
| 63 | + $_SESSION['Permission']['HumanNameValue'] = ''; | ||
| 64 | + } | ||
| 65 | + | ||
| 54 | $oTemplating =& KTTemplating::getSingleton(); | 66 | $oTemplating =& KTTemplating::getSingleton(); |
| 55 | $aPermissions =& KTPermission::getList(); | 67 | $aPermissions =& KTPermission::getList(); |
| 56 | $oTemplate = $oTemplating->loadTemplate("ktcore/manage_permissions"); | 68 | $oTemplate = $oTemplating->loadTemplate("ktcore/manage_permissions"); |
| @@ -63,17 +75,75 @@ class ManagePermissionsDispatcher extends KTAdminDispatcher { | @@ -63,17 +75,75 @@ class ManagePermissionsDispatcher extends KTAdminDispatcher { | ||
| 63 | } | 75 | } |
| 64 | 76 | ||
| 65 | function do_newPermission() { | 77 | function do_newPermission() { |
| 66 | - $name = KTUtil::arrayGet($_REQUEST, 'name'); | ||
| 67 | - $human_name = KTUtil::arrayGet($_REQUEST, 'human_name'); | ||
| 68 | - if (empty($name) || empty($human_name)) { | ||
| 69 | - return $this->errorRedirectToMain(_kt("Both names not given")); | 78 | + session_start(); |
| 79 | + $sName = KTUtil::arrayGet($_REQUEST, 'name'); | ||
| 80 | + $sHumanName = KTUtil::arrayGet($_REQUEST, 'human_name'); | ||
| 81 | + $sError = 'An error occured while creating your permission'; | ||
| 82 | + | ||
| 83 | + //Checking that the System Name and Display Name fields aren't empty | ||
| 84 | + if (empty($sName) && !empty($sHumanName)) | ||
| 85 | + { | ||
| 86 | + $sError = 'An error occured while creating your permission: The System Name was not provided.'; | ||
| 87 | + $_SESSION['Permission']['HumanNameValue'] = $sHumanName; | ||
| 88 | + return $this->errorRedirectToMain(_kt($sError)); | ||
| 70 | } | 89 | } |
| 71 | - $oPerm = KTPermission::createFromArray(array( | ||
| 72 | - 'name' => $name, | ||
| 73 | - 'humanname' => $human_name, | 90 | + else if(!empty($sName) && empty($sHumanName)) |
| 91 | + { | ||
| 92 | + $sError = 'An error occured while creating your permission: The Display Name was not provided.'; | ||
| 93 | + $_SESSION['Permission']['NameValue'] = $sName; | ||
| 94 | + return $this->errorRedirectToMain(_kt($sError)); | ||
| 95 | + } | ||
| 96 | + else if (empty($sName) && empty($sHumanName)) | ||
| 97 | + { | ||
| 98 | + $sError = 'An error occured while creating your permission: The Display Name and System Name weren\'t provided.'; | ||
| 99 | + return $this->errorRedirectToMain(_kt($sError)); | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + //Checking that the System Name and Display Name aren't already in the database | ||
| 103 | + $aPermissions = KTPermission::getList(); | ||
| 104 | + //$iNameErrorCount and $iHumanNameErrorCount are used to check whether only one name is duplicated or if two names are duplicated. | ||
| 105 | + $iNameErrorCount = 0; | ||
| 106 | + $iHumanNameErrorCount = 0; | ||
| 107 | + foreach ($aPermissions as $aPermission) | ||
| 108 | + { | ||
| 109 | + if($sName == $aPermission->getName()) | ||
| 110 | + { | ||
| 111 | + $iNameErrorCount ++; | ||
| 112 | + } | ||
| 113 | + if ($sHumanName == $aPermission->getHumanName()) | ||
| 114 | + { | ||
| 115 | + $iHumanNameErrorCount ++; | ||
| 116 | + } | ||
| 117 | + } | ||
| 118 | + if ($iNameErrorCount > 0 && $iHumanNameErrorCount > 0) | ||
| 119 | + { | ||
| 120 | + $sError = 'An error occured while creating your permission: The Display Name and System Name you have provided both already exist.'; | ||
| 121 | + return $this->errorRedirectToMain(_kt($sError)); | ||
| 122 | + } | ||
| 123 | + else if ($iNameErrorCount > 0 && $iHumanNameErrorCount == 0) | ||
| 124 | + { | ||
| 125 | + if(!empty($sHumanName)) | ||
| 126 | + { | ||
| 127 | + $_SESSION['Permission']['HumanNameValue'] = $sHumanName; | ||
| 128 | + } | ||
| 129 | + $sError = 'An error occured while creating your permission: A permission with the same System Name already exists.'; | ||
| 130 | + return $this->errorRedirectToMain(_kt($sError)); | ||
| 131 | + } | ||
| 132 | + else if ($iNameErrorCount == 0 && $iHumanNameErrorCount > 0) | ||
| 133 | + { | ||
| 134 | + if(!empty($sName)) | ||
| 135 | + { | ||
| 136 | + $_SESSION['Permission']['NameValue'] = $sName; | ||
| 137 | + } | ||
| 138 | + $sError = 'An error occured while creating your permission: A permission with the same Display Name already exists.'; | ||
| 139 | + return $this->errorRedirectToMain(_kt($sError)); | ||
| 140 | + } | ||
| 141 | + $oPerm = KTPermission::createFromArray(array( | ||
| 142 | + 'name' => $sName, | ||
| 143 | + 'humanname' => $sHumanName, | ||
| 74 | )); | 144 | )); |
| 75 | if (PEAR::isError($oPerm)) { | 145 | if (PEAR::isError($oPerm)) { |
| 76 | - return $this->errorRedirectToMain(_kt("Error creating permission")); | 146 | + return $this->errorRedirectToMain(_kt($sError)); |
| 77 | } | 147 | } |
| 78 | return $this->successRedirectToMain(_kt("Permission created")); | 148 | return $this->successRedirectToMain(_kt("Permission created")); |
| 79 | } | 149 | } |
plugins/rssplugin/loadFeed.inc.php
| 1 | <?php | 1 | <?php |
| 2 | /* | 2 | /* |
| 3 | - * $Id:$ | 3 | + * $Id$ |
| 4 | * | 4 | * |
| 5 | * KnowledgeTree Open Source Edition | 5 | * KnowledgeTree Open Source Edition |
| 6 | * Document Management Made Simple | 6 | * Document Management Made Simple |
| @@ -49,13 +49,19 @@ | @@ -49,13 +49,19 @@ | ||
| 49 | // If it is a url, it is an external feed | 49 | // If it is a url, it is an external feed |
| 50 | $aRSSArray = rss2array($feed); | 50 | $aRSSArray = rss2array($feed); |
| 51 | } | 51 | } |
| 52 | - | 52 | + if(count($aRSSArray[errors]) > 0){ |
| 53 | + for($i=0;$i<count($aRSSArray[errors]);$i++){ | ||
| 54 | + $response .= $aRSSArray[errors][$i].'<br>'; | ||
| 55 | + echo '<br>'.$response.'<br>'; | ||
| 56 | + return; | ||
| 57 | + } | ||
| 58 | + } | ||
| 53 | // Prepare response data to be passed back to page | 59 | // Prepare response data to be passed back to page |
| 54 | - $reposonse = "<h3>".$aRSSArray[channel][title]."</h3>" . | 60 | + $response = "<h3>".$aRSSArray[channel][title]."</h3>" . |
| 55 | "<div class='outerContainer' id='outerContainer'>" . | 61 | "<div class='outerContainer' id='outerContainer'>" . |
| 56 | "<table width='90%'>"; | 62 | "<table width='90%'>"; |
| 57 | for($i=0;$i<count($aRSSArray[items]);$i++){ | 63 | for($i=0;$i<count($aRSSArray[items]);$i++){ |
| 58 | - $reposonse .= "<tr> | 64 | + $response .= "<tr> |
| 59 | <td colspan='2'><strong><a href='".$aRSSArray[items][$i][link]."' target='_blank'>".$aRSSArray[items][$i][title]."</a><strong></td> | 65 | <td colspan='2'><strong><a href='".$aRSSArray[items][$i][link]."' target='_blank'>".$aRSSArray[items][$i][title]."</a><strong></td> |
| 60 | </tr> | 66 | </tr> |
| 61 | <tr> | 67 | <tr> |
| @@ -63,7 +69,7 @@ | @@ -63,7 +69,7 @@ | ||
| 63 | </tr> | 69 | </tr> |
| 64 | <tr><td colspan='2'><br></td></tr>"; | 70 | <tr><td colspan='2'><br></td></tr>"; |
| 65 | } | 71 | } |
| 66 | - $reposonse .= "</table></div><br>"; | 72 | + $response .= "</table></div><br>"; |
| 67 | 73 | ||
| 68 | - echo $reposonse; | 74 | + echo $response; |
| 69 | ?> | 75 | ?> |
plugins/rssplugin/rss2array.inc.php
| 1 | <?php | 1 | <?php |
| 2 | 2 | ||
| 3 | /* | 3 | /* |
| 4 | - * $Id:$ | 4 | + * $Id$ |
| 5 | * | 5 | * |
| 6 | * KnowledgeTree Open Source Edition | 6 | * KnowledgeTree Open Source Edition |
| 7 | * Document Management Made Simple | 7 | * Document Management Made Simple |
| @@ -80,8 +80,8 @@ | @@ -80,8 +80,8 @@ | ||
| 80 | # | 80 | # |
| 81 | # open the connection | 81 | # open the connection |
| 82 | # | 82 | # |
| 83 | - | ||
| 84 | - if($http = fsockopen($host, $port, $errno, $errstr, 5)){ | 83 | + $http = @fsockopen($host, $port, $errno, $errstr, 5); |
| 84 | + if($http){ | ||
| 85 | 85 | ||
| 86 | # | 86 | # |
| 87 | # make the request | 87 | # make the request |
| @@ -169,7 +169,6 @@ | @@ -169,7 +169,6 @@ | ||
| 169 | # | 169 | # |
| 170 | 170 | ||
| 171 | else { | 171 | else { |
| 172 | - | ||
| 173 | $rss2array_globals[errors][] = "Can't connect to $host"; | 172 | $rss2array_globals[errors][] = "Can't connect to $host"; |
| 174 | 173 | ||
| 175 | } | 174 | } |
plugins/search2/ExternalDashlet.php
| @@ -104,7 +104,7 @@ class ExternalResourceStatusDashlet extends KTBaseDashlet | @@ -104,7 +104,7 @@ class ExternalResourceStatusDashlet extends KTBaseDashlet | ||
| 104 | 104 | ||
| 105 | function checkDF() | 105 | function checkDF() |
| 106 | { | 106 | { |
| 107 | - $df = KTUtil::findCommand('externalBinary','df'); | 107 | + $df = KTUtil::findCommand('externalBinary/df','df'); |
| 108 | 108 | ||
| 109 | if (false === $df) | 109 | if (false === $df) |
| 110 | { | 110 | { |
resources/graphics/download.png
search2/indexing/bin/optimise.php
| @@ -46,11 +46,15 @@ chdir(dirname(__FILE__)); | @@ -46,11 +46,15 @@ chdir(dirname(__FILE__)); | ||
| 46 | require_once(realpath('../../../config/dmsDefaults.php')); | 46 | require_once(realpath('../../../config/dmsDefaults.php')); |
| 47 | require_once('indexing/indexerCore.inc.php'); | 47 | require_once('indexing/indexerCore.inc.php'); |
| 48 | 48 | ||
| 49 | -print _kt("Optimising Lucene index") . "...\n"; | 49 | +$verbose = false; |
| 50 | + | ||
| 51 | +if (is_array($argv) && in_array('verbose', $argv)) $verbose = true; | ||
| 52 | + | ||
| 53 | +if ($verbose) print _kt("Optimising Lucene index") . "...\n"; | ||
| 50 | 54 | ||
| 51 | $indexer = Indexer::get(); | 55 | $indexer = Indexer::get(); |
| 52 | $indexer->optimise(); | 56 | $indexer->optimise(); |
| 53 | 57 | ||
| 54 | -print _kt("Done.") . "\n"; | 58 | +if ($verbose) print _kt("Done.") . "\n"; |
| 55 | 59 | ||
| 56 | ?> | 60 | ?> |
| 57 | \ No newline at end of file | 61 | \ No newline at end of file |
search2/indexing/indexerCore.inc.php
| @@ -37,7 +37,7 @@ | @@ -37,7 +37,7 @@ | ||
| 37 | */ | 37 | */ |
| 38 | 38 | ||
| 39 | require_once('indexing/extractorCore.inc.php'); | 39 | require_once('indexing/extractorCore.inc.php'); |
| 40 | - | 40 | +require_once(KT_DIR . '/plugins/ktcore/scheduler/schedulerUtil.php'); |
| 41 | 41 | ||
| 42 | class QueryResultItem | 42 | class QueryResultItem |
| 43 | { | 43 | { |
| @@ -306,16 +306,14 @@ abstract class Indexer | @@ -306,16 +306,14 @@ abstract class Indexer | ||
| 306 | */ | 306 | */ |
| 307 | protected function __construct() | 307 | protected function __construct() |
| 308 | { | 308 | { |
| 309 | - $this->extractorCache=array(); | ||
| 310 | - $this->debug=true; | ||
| 311 | - $this->hookCache = array(); | ||
| 312 | - $this->generalHookCache = array(); | ||
| 313 | - | ||
| 314 | $config = KTConfig::getSingleton(); | 309 | $config = KTConfig::getSingleton(); |
| 315 | 310 | ||
| 316 | - $this->extractorPath = $config->get('indexer/extractorPath', 'extractors'); | ||
| 317 | - $this->hookPath = $config->get('indexer/extractorHookPath','extractorHooks'); | ||
| 318 | - | 311 | + $this->extractorCache = array(); |
| 312 | + $this->debug = $config->get('indexer/debug', true); | ||
| 313 | + $this->hookCache = array(); | ||
| 314 | + $this->generalHookCache = array(); | ||
| 315 | + $this->extractorPath = $config->get('indexer/extractorPath', 'extractors'); | ||
| 316 | + $this->hookPath = $config->get('indexer/extractorHookPath','extractorHooks'); | ||
| 319 | 317 | ||
| 320 | $this->loadExtractorStatus(); | 318 | $this->loadExtractorStatus(); |
| 321 | } | 319 | } |
| @@ -383,7 +381,7 @@ abstract class Indexer | @@ -383,7 +381,7 @@ abstract class Indexer | ||
| 383 | $sql = "delete from mime_extractors"; | 381 | $sql = "delete from mime_extractors"; |
| 384 | DBUtil::runQuery($sql); | 382 | DBUtil::runQuery($sql); |
| 385 | 383 | ||
| 386 | - $default->log->debug('clearExtractors'); | 384 | + if ($this->debug) $default->log->debug('clearExtractors'); |
| 387 | } | 385 | } |
| 388 | 386 | ||
| 389 | /** | 387 | /** |
| @@ -453,7 +451,7 @@ abstract class Indexer | @@ -453,7 +451,7 @@ abstract class Indexer | ||
| 453 | $sql = "INSERT INTO index_files(document_id, user_id, what) VALUES($document_id, $userid, '$what')"; | 451 | $sql = "INSERT INTO index_files(document_id, user_id, what) VALUES($document_id, $userid, '$what')"; |
| 454 | DBUtil::runQuery($sql); | 452 | DBUtil::runQuery($sql); |
| 455 | 453 | ||
| 456 | -// if ($this->debug) $default->log->debug("index: Queuing indexing of $document_id"); | 454 | + $default->log->debug("index: Queuing indexing of $document_id"); |
| 457 | } | 455 | } |
| 458 | 456 | ||
| 459 | 457 | ||
| @@ -487,7 +485,7 @@ abstract class Indexer | @@ -487,7 +485,7 @@ abstract class Indexer | ||
| 487 | );'; | 485 | );'; |
| 488 | DBUtil::runQuery($sql); | 486 | DBUtil::runQuery($sql); |
| 489 | 487 | ||
| 490 | - // if ($this->debug) $default->log->debug("clearoutDeleted: remove documents"); | 488 | + $default->log->debug("Indexer::clearoutDeleted: removed documents from indexing queue that have been deleted"); |
| 491 | } | 489 | } |
| 492 | 490 | ||
| 493 | 491 | ||
| @@ -679,7 +677,7 @@ abstract class Indexer | @@ -679,7 +677,7 @@ abstract class Indexer | ||
| 679 | { | 677 | { |
| 680 | return; | 678 | return; |
| 681 | } | 679 | } |
| 682 | - $default->log->info('checkForRegisteredTypes: start'); | 680 | + if ($this->debug) $default->log->debug('checkForRegisteredTypes: start'); |
| 683 | 681 | ||
| 684 | $date = date('Y-m-d H:i'); | 682 | $date = date('Y-m-d H:i'); |
| 685 | $sql = "UPDATE scheduler_tasks SET run_time='$date'"; | 683 | $sql = "UPDATE scheduler_tasks SET run_time='$date'"; |
| @@ -701,7 +699,7 @@ abstract class Indexer | @@ -701,7 +699,7 @@ abstract class Indexer | ||
| 701 | $default->log->info("checkForRegisteredTypes: disabled '$extractor'"); | 699 | $default->log->info("checkForRegisteredTypes: disabled '$extractor'"); |
| 702 | } | 700 | } |
| 703 | 701 | ||
| 704 | - $default->log->info('checkForRegisteredTypes: done'); | 702 | + if ($this->debug) $default->log->debug('checkForRegisteredTypes: done'); |
| 705 | KTUtil::setSystemSetting('mimeTypesRegistered', true); | 703 | KTUtil::setSystemSetting('mimeTypesRegistered', true); |
| 706 | } | 704 | } |
| 707 | 705 | ||
| @@ -728,10 +726,11 @@ abstract class Indexer | @@ -728,10 +726,11 @@ abstract class Indexer | ||
| 728 | 726 | ||
| 729 | $this->checkForRegisteredTypes(); | 727 | $this->checkForRegisteredTypes(); |
| 730 | 728 | ||
| 731 | - $default->log->info('indexDocuments: start'); | 729 | + if ($this->debug) $default->log->debug('indexDocuments: start'); |
| 732 | if (!$this->doesDiagnosticsPass()) | 730 | if (!$this->doesDiagnosticsPass()) |
| 733 | { | 731 | { |
| 734 | //unlink($indexLockFile); | 732 | //unlink($indexLockFile); |
| 733 | + if ($this->debug) $default->log->debug('indexDocuments: stopping - diagnostics problem. The dashboard will provide more information.'); | ||
| 735 | return; | 734 | return; |
| 736 | } | 735 | } |
| 737 | 736 | ||
| @@ -764,6 +763,7 @@ abstract class Indexer | @@ -764,6 +763,7 @@ abstract class Indexer | ||
| 764 | if (PEAR::isError($result)) | 763 | if (PEAR::isError($result)) |
| 765 | { | 764 | { |
| 766 | //unlink($indexLockFile); | 765 | //unlink($indexLockFile); |
| 766 | + if ($this->debug) $default->log->debug('indexDocuments: stopping - db error'); | ||
| 767 | return; | 767 | return; |
| 768 | } | 768 | } |
| 769 | 769 | ||
| @@ -771,6 +771,7 @@ abstract class Indexer | @@ -771,6 +771,7 @@ abstract class Indexer | ||
| 771 | if (count($result) == 0) | 771 | if (count($result) == 0) |
| 772 | { | 772 | { |
| 773 | //unlink($indexLockFile); | 773 | //unlink($indexLockFile); |
| 774 | + if ($this->debug) $default->log->debug('indexDocuments: stopping - no work to be done'); | ||
| 774 | return; | 775 | return; |
| 775 | } | 776 | } |
| 776 | 777 | ||
| @@ -804,17 +805,12 @@ abstract class Indexer | @@ -804,17 +805,12 @@ abstract class Indexer | ||
| 804 | 805 | ||
| 805 | if ($this->debug) | 806 | if ($this->debug) |
| 806 | { | 807 | { |
| 807 | - $default->log->debug(sprintf(_kt("Indexing docid: %d extension: '%s' mimetype: '%s' extractor: '%s'"), $docId, $extension,$mimeType,$extractorClass)); | 808 | + if ($this->debug) $default->log->debug(sprintf(_kt("Indexing docid: %d extension: '%s' mimetype: '%s' extractor: '%s'"), $docId, $extension,$mimeType,$extractorClass)); |
| 808 | } | 809 | } |
| 809 | 810 | ||
| 810 | if (empty($extractorClass)) | 811 | if (empty($extractorClass)) |
| 811 | { | 812 | { |
| 812 | - if ($this->debug) | ||
| 813 | - { | ||
| 814 | - $default->log->debug(sprintf(_kt("No extractor for docid: %d"),$docId)); | ||
| 815 | - } | ||
| 816 | - | ||
| 817 | - Indexer::unqueueDocument($docId); | 813 | + Indexer::unqueueDocument($docId, sprintf(_kt("No extractor for docid: %d"),$docId)); |
| 818 | continue; | 814 | continue; |
| 819 | } | 815 | } |
| 820 | 816 | ||
| @@ -867,8 +863,7 @@ abstract class Indexer | @@ -867,8 +863,7 @@ abstract class Indexer | ||
| 867 | 863 | ||
| 868 | if (empty($sourceFile) || !is_file($sourceFile)) | 864 | if (empty($sourceFile) || !is_file($sourceFile)) |
| 869 | { | 865 | { |
| 870 | - $default->log->error(sprintf(_kt("indexDocuments: source file '%s' for document %d does not exist."),$sourceFile,$docId)); | ||
| 871 | - Indexer::unqueueDocument($docId); | 866 | + Indexer::unqueueDocument($docId,sprintf(_kt("indexDocuments: source file '%s' for document %d does not exist."),$sourceFile,$docId), 'error'); |
| 872 | continue; | 867 | continue; |
| 873 | } | 868 | } |
| 874 | 869 | ||
| @@ -896,10 +891,8 @@ abstract class Indexer | @@ -896,10 +891,8 @@ abstract class Indexer | ||
| 896 | $extractor->setDocument($document); | 891 | $extractor->setDocument($document); |
| 897 | $extractor->setIndexingStatus(null); | 892 | $extractor->setIndexingStatus(null); |
| 898 | $extractor->setExtractionStatus(null); | 893 | $extractor->setExtractionStatus(null); |
| 899 | - if ($this->debug) | ||
| 900 | - { | ||
| 901 | - $default->log->debug(sprintf(_kt("Extra Info docid: %d Source File: '%s' Target File: '%s'"),$docId,$sourceFile,$targetFile)); | ||
| 902 | - } | 894 | + |
| 895 | + if ($this->debug) $default->log->debug(sprintf(_kt("Extra Info docid: %d Source File: '%s' Target File: '%s'"),$docId,$sourceFile,$targetFile)); | ||
| 903 | 896 | ||
| 904 | $this->executeHook($extractor, 'pre_extract'); | 897 | $this->executeHook($extractor, 'pre_extract'); |
| 905 | $this->executeHook($extractor, 'pre_extract', $mimeType); | 898 | $this->executeHook($extractor, 'pre_extract', $mimeType); |
| @@ -971,22 +964,32 @@ abstract class Indexer | @@ -971,22 +964,32 @@ abstract class Indexer | ||
| 971 | 964 | ||
| 972 | if ($removeFromQueue) | 965 | if ($removeFromQueue) |
| 973 | { | 966 | { |
| 974 | - Indexer::unqueueDocument($docId); | 967 | + Indexer::unqueueDocument($docId, sprintf(_kt("Done indexing docid: %d"),$docId)); |
| 968 | + } | ||
| 969 | + else | ||
| 970 | + { | ||
| 971 | + if ($this->debug) $default->log->debug(sprintf(_kt("Document docid: %d was not removed from the queue as it looks like there was a problem with the extraction process"),$docId)); | ||
| 975 | } | 972 | } |
| 976 | - if ($this->debug) | ||
| 977 | - { | ||
| 978 | - $default->log->debug(sprintf(_kt("Done indexing docid: %d"),$docId)); | ||
| 979 | - } | ||
| 980 | - | ||
| 981 | } | 973 | } |
| 982 | - $default->log->info('indexDocuments: done'); | 974 | + if ($this->debug) $default->log->debug('indexDocuments: done'); |
| 983 | //unlink($indexLockFile); | 975 | //unlink($indexLockFile); |
| 984 | } | 976 | } |
| 985 | 977 | ||
| 986 | public function migrateDocuments($max=null) | 978 | public function migrateDocuments($max=null) |
| 987 | { | 979 | { |
| 980 | + global $default; | ||
| 981 | + | ||
| 982 | + $default->log->info(_kt('migrateDocuments: starting')); | ||
| 983 | + | ||
| 988 | if (!$this->doesDiagnosticsPass(true)) | 984 | if (!$this->doesDiagnosticsPass(true)) |
| 989 | { | 985 | { |
| 986 | + $default->log->info(_kt('migrateDocuments: stopping - diagnostics problem. The dashboard will provide more information.')); | ||
| 987 | + return; | ||
| 988 | + } | ||
| 989 | + | ||
| 990 | + if (KTUtil::getSystemSetting('migrationComplete') == 'true') | ||
| 991 | + { | ||
| 992 | + $default->log->info(_kt('migrateDocuments: stopping - migration is complete.')); | ||
| 990 | return; | 993 | return; |
| 991 | } | 994 | } |
| 992 | 995 | ||
| @@ -996,16 +999,13 @@ abstract class Indexer | @@ -996,16 +999,13 @@ abstract class Indexer | ||
| 996 | $max = $config->get('indexer/batchMigrateDocument',500); | 999 | $max = $config->get('indexer/batchMigrateDocument',500); |
| 997 | } | 1000 | } |
| 998 | 1001 | ||
| 999 | - global $default; | ||
| 1000 | - | ||
| 1001 | $lockFile = $config->get('cache/cacheDirectory') . '/migration.lock'; | 1002 | $lockFile = $config->get('cache/cacheDirectory') . '/migration.lock'; |
| 1002 | if (is_file($lockFile)) | 1003 | if (is_file($lockFile)) |
| 1003 | { | 1004 | { |
| 1004 | - $default->log->info(_kt('migrateDocuments: migration lockfile detected. exiting.')); | 1005 | + $default->log->info(_kt('migrateDocuments: stopping - migration lockfile detected.')); |
| 1005 | return; | 1006 | return; |
| 1006 | } | 1007 | } |
| 1007 | touch($lockFile); | 1008 | touch($lockFile); |
| 1008 | - $default->log->info(_kt('migrateDocuments: starting!')); | ||
| 1009 | 1009 | ||
| 1010 | $startTime = KTUtil::getSystemSetting('migrationStarted'); | 1010 | $startTime = KTUtil::getSystemSetting('migrationStarted'); |
| 1011 | if (is_null($startTime)) | 1011 | if (is_null($startTime)) |
| @@ -1015,7 +1015,7 @@ abstract class Indexer | @@ -1015,7 +1015,7 @@ abstract class Indexer | ||
| 1015 | 1015 | ||
| 1016 | $maxLoops = 5; | 1016 | $maxLoops = 5; |
| 1017 | 1017 | ||
| 1018 | - $max = floor($max / $maxLoops); | 1018 | + $max = ceil($max / $maxLoops); |
| 1019 | 1019 | ||
| 1020 | $start =KTUtil::getBenchmarkTime(); | 1020 | $start =KTUtil::getBenchmarkTime(); |
| 1021 | $noDocs = false; | 1021 | $noDocs = false; |
| @@ -1033,6 +1033,7 @@ abstract class Indexer | @@ -1033,6 +1033,7 @@ abstract class Indexer | ||
| 1033 | $result = DBUtil::getResultArray($sql); | 1033 | $result = DBUtil::getResultArray($sql); |
| 1034 | if (PEAR::isError($result)) | 1034 | if (PEAR::isError($result)) |
| 1035 | { | 1035 | { |
| 1036 | + $default->log->info(_kt('migrateDocuments: db error')); | ||
| 1036 | break; | 1037 | break; |
| 1037 | } | 1038 | } |
| 1038 | 1039 | ||
| @@ -1053,7 +1054,7 @@ abstract class Indexer | @@ -1053,7 +1054,7 @@ abstract class Indexer | ||
| 1053 | { | 1054 | { |
| 1054 | $sql = "DELETE FROM document_text WHERE document_id=$docId"; | 1055 | $sql = "DELETE FROM document_text WHERE document_id=$docId"; |
| 1055 | DBUtil::runQuery($sql); | 1056 | DBUtil::runQuery($sql); |
| 1056 | - $default->log->error(sprintf(_kt('migrateDocuments: Could not get document %d\'s document! Removing content!',$docId))); | 1057 | + $default->log->error(sprintf(_kt('migrateDocuments: Could not get document %d\'s document! Removing content!'),$docId)); |
| 1057 | continue; | 1058 | continue; |
| 1058 | } | 1059 | } |
| 1059 | 1060 | ||
| @@ -1094,13 +1095,14 @@ abstract class Indexer | @@ -1094,13 +1095,14 @@ abstract class Indexer | ||
| 1094 | KTUtil::setSystemSetting('migrationTime', KTUtil::getSystemSetting('migrationTime',0) + $time); | 1095 | KTUtil::setSystemSetting('migrationTime', KTUtil::getSystemSetting('migrationTime',0) + $time); |
| 1095 | KTUtil::setSystemSetting('migratedDocuments', KTUtil::getSystemSetting('migratedDocuments',0) + $numDocs); | 1096 | KTUtil::setSystemSetting('migratedDocuments', KTUtil::getSystemSetting('migratedDocuments',0) + $numDocs); |
| 1096 | 1097 | ||
| 1097 | - $default->log->info(sprintf(_kt('migrateDocuments: done in %d seconds!'), $time)); | 1098 | + $default->log->info(sprintf(_kt('migrateDocuments: stopping - done in %d seconds!'), $time)); |
| 1098 | if ($noDocs) | 1099 | if ($noDocs) |
| 1099 | { | 1100 | { |
| 1100 | $default->log->info(_kt('migrateDocuments: Completed!')); | 1101 | $default->log->info(_kt('migrateDocuments: Completed!')); |
| 1101 | - KTUtil::setSystemSetting('migrationComplete', true); | 1102 | + KTUtil::setSystemSetting('migrationComplete', 'true'); |
| 1103 | + schedulerUtil::deleteByName('Index Migration'); | ||
| 1104 | + $default->log->debug(_kt('migrateDocuments: Disabling \'Index Migration\' task by removing scheduler entry.')); | ||
| 1102 | } | 1105 | } |
| 1103 | - | ||
| 1104 | } | 1106 | } |
| 1105 | 1107 | ||
| 1106 | /** | 1108 | /** |
| @@ -1176,7 +1178,7 @@ abstract class Indexer | @@ -1176,7 +1178,7 @@ abstract class Indexer | ||
| 1176 | 1178 | ||
| 1177 | if (!$this->isExtractorEnabled($class)) | 1179 | if (!$this->isExtractorEnabled($class)) |
| 1178 | { | 1180 | { |
| 1179 | - $default->log->info(sprintf(_kt("diagnose: extractor '%s' is disabled."), $class)); | 1181 | + $default->log->debug(sprintf(_kt("diagnose: extractor '%s' is disabled."), $class)); |
| 1180 | continue; | 1182 | continue; |
| 1181 | } | 1183 | } |
| 1182 | 1184 | ||
| @@ -1263,10 +1265,15 @@ abstract class Indexer | @@ -1263,10 +1265,15 @@ abstract class Indexer | ||
| 1263 | * | 1265 | * |
| 1264 | * @param int $docid | 1266 | * @param int $docid |
| 1265 | */ | 1267 | */ |
| 1266 | - public static function unqueueDocument($docid) | 1268 | + public static function unqueueDocument($docid, $reason=false, $level='debug') |
| 1267 | { | 1269 | { |
| 1268 | $sql = "DELETE FROM index_files WHERE document_id=$docid"; | 1270 | $sql = "DELETE FROM index_files WHERE document_id=$docid"; |
| 1269 | DBUtil::runQuery($sql); | 1271 | DBUtil::runQuery($sql); |
| 1272 | + if ($reason !== false) | ||
| 1273 | + { | ||
| 1274 | + global $default; | ||
| 1275 | + $default->log->$level("Indexer: removing document $docid from the queue - $reason"); | ||
| 1276 | + } | ||
| 1270 | } | 1277 | } |
| 1271 | 1278 | ||
| 1272 | /** | 1279 | /** |
| @@ -1343,6 +1350,18 @@ abstract class Indexer | @@ -1343,6 +1350,18 @@ abstract class Indexer | ||
| 1343 | * @return int | 1350 | * @return int |
| 1344 | */ | 1351 | */ |
| 1345 | public abstract function getDocumentsInIndex(); | 1352 | public abstract function getDocumentsInIndex(); |
| 1353 | + | ||
| 1354 | + /** | ||
| 1355 | + * Returns the path to the index directory | ||
| 1356 | + * | ||
| 1357 | + * @return string | ||
| 1358 | + */ | ||
| 1359 | + public function getIndexDirectory() | ||
| 1360 | + { | ||
| 1361 | + $config = KTConfig::getSingleton(); | ||
| 1362 | + $directory = $config->get('indexer/luceneDirectory'); | ||
| 1363 | + return $directory; | ||
| 1364 | + } | ||
| 1346 | } | 1365 | } |
| 1347 | 1366 | ||
| 1348 | ?> | 1367 | ?> |
| 1349 | \ No newline at end of file | 1368 | \ No newline at end of file |
search2/indexing/indexers/JavaXMLRPCLuceneIndexer.inc.php
| @@ -250,5 +250,20 @@ class JavaXMLRPCLuceneIndexer extends Indexer | @@ -250,5 +250,20 @@ class JavaXMLRPCLuceneIndexer extends Indexer | ||
| 250 | return $stats->countDocuments; | 250 | return $stats->countDocuments; |
| 251 | } | 251 | } |
| 252 | 252 | ||
| 253 | + /** | ||
| 254 | + * Returns the path to the index directory | ||
| 255 | + * | ||
| 256 | + * @return string | ||
| 257 | + */ | ||
| 258 | + public function getIndexDirectory() | ||
| 259 | + { | ||
| 260 | + $stats = $this->lucene->getStatistics(); | ||
| 261 | + if ($stats === false || !is_object($stats)) | ||
| 262 | + { | ||
| 263 | + return false; | ||
| 264 | + } | ||
| 265 | + return $stats->indexDirectory; | ||
| 266 | + } | ||
| 267 | + | ||
| 253 | } | 268 | } |
| 254 | ?> | 269 | ?> |
| 255 | \ No newline at end of file | 270 | \ No newline at end of file |
search2/search/fields/AnyMetadataField.inc.php
| @@ -40,7 +40,7 @@ class AnyMetadataField extends DBFieldExpr | @@ -40,7 +40,7 @@ class AnyMetadataField extends DBFieldExpr | ||
| 40 | { | 40 | { |
| 41 | public function __construct() | 41 | public function __construct() |
| 42 | { | 42 | { |
| 43 | - parent::__construct('id', 'document_fields_link', _kt('Any Metadata')); | 43 | + parent::__construct('value', 'document_fields_link', _kt('Any Metadata')); |
| 44 | $this->setAlias('Metadata'); | 44 | $this->setAlias('Metadata'); |
| 45 | } | 45 | } |
| 46 | 46 |
search2/search/search.inc.php
| @@ -263,6 +263,14 @@ class SearchHelper | @@ -263,6 +263,14 @@ class SearchHelper | ||
| 263 | 263 | ||
| 264 | public static function getSavedSearches($userID) | 264 | public static function getSavedSearches($userID) |
| 265 | { | 265 | { |
| 266 | + | ||
| 267 | + // need to test for broken db configuration so that the queries dont fail | ||
| 268 | + // and so that we can be redirected to the db error page | ||
| 269 | + // TODO: maybe best to have a special db error page rather than the default template when logged in | ||
| 270 | + | ||
| 271 | + global $default; | ||
| 272 | + if (is_null($default->_db) || PEAR::isError($default->_db)) return array(); | ||
| 273 | + | ||
| 266 | $sql = "SELECT id, name FROM search_saved WHERE type='S'"; | 274 | $sql = "SELECT id, name FROM search_saved WHERE type='S'"; |
| 267 | 275 | ||
| 268 | // if we are not the system admin, then we get only ours or shared searches | 276 | // if we are not the system admin, then we get only ours or shared searches |
| @@ -532,6 +540,52 @@ function parseExpression($expr_str) | @@ -532,6 +540,52 @@ function parseExpression($expr_str) | ||
| 532 | return $parser->getExprResult(); | 540 | return $parser->getExprResult(); |
| 533 | } | 541 | } |
| 534 | 542 | ||
| 535 | - | 543 | +function processSearchExpression($query) |
| 544 | +{ | ||
| 545 | + try | ||
| 546 | + { | ||
| 547 | + $expr = parseExpression($query); | ||
| 548 | + | ||
| 549 | + $rs = $expr->evaluate(); | ||
| 550 | + usort($rs, 'rank_compare'); | ||
| 551 | + | ||
| 552 | + $results = array(); | ||
| 553 | + foreach($rs as $hit) | ||
| 554 | + { | ||
| 555 | + $item = array( | ||
| 556 | + 'document_id' => (int) $hit->DocumentID, | ||
| 557 | + 'title' => (string) $hit->Title, | ||
| 558 | + 'relevance' => (float) $hit->Rank, | ||
| 559 | + 'text' => (string) $noText?'':$hit->Text, | ||
| 560 | + 'filesize' => (int) $hit->Filesize, | ||
| 561 | + 'fullpath' => (string) $hit->FullPath, | ||
| 562 | + 'version' => (string) $hit->Version, | ||
| 563 | + 'filename' => (string) $hit->Filename, | ||
| 564 | + 'checked_out_by' => (string) $hit->CheckedOutUser, | ||
| 565 | + 'checked_out_date' => (string) $hit->DateCheckedOut, | ||
| 566 | + 'is_available' => (bool) $hit->IsAvailable, | ||
| 567 | + 'workflow' => (string) $hit->Workflow, | ||
| 568 | + 'workflow_state' => (string) $hit->WorkflowState, | ||
| 569 | + 'folder_id' => (int) $hit->FolderId, | ||
| 570 | + 'mime_type' => (string) $hit->MimeType, | ||
| 571 | + 'modified_by' => (string) $hit->ModifiedBy, | ||
| 572 | + 'modified_date' => (string) $hit->DateModified, | ||
| 573 | + 'created_by' => (string) $hit->CreatedBy, | ||
| 574 | + 'created_date' => (string) $hit->DateCreated, | ||
| 575 | + 'owner' => (string) $hit->Owner, | ||
| 576 | + 'is_immutable'=> (bool) $hit->Immutable, | ||
| 577 | + 'status' => (string) $hit->Status | ||
| 578 | + ); | ||
| 579 | + | ||
| 580 | + $results[] = $item; | ||
| 581 | + | ||
| 582 | + } | ||
| 583 | + return $results; | ||
| 584 | + } | ||
| 585 | + catch(Exception $e) | ||
| 586 | + { | ||
| 587 | + return new PEAR_Error(_kt('Could not process query.') . $e->getMessage()); | ||
| 588 | + } | ||
| 589 | +} | ||
| 536 | 590 | ||
| 537 | ?> | 591 | ?> |
| 538 | \ No newline at end of file | 592 | \ No newline at end of file |
sql/mysql/install/data.sql
No preview for this file type
templates/ktcore/login.smarty
| @@ -30,7 +30,13 @@ | @@ -30,7 +30,13 @@ | ||
| 30 | {if ($errorMessage == null)} | 30 | {if ($errorMessage == null)} |
| 31 | <p class="descriptiveText">{i18n}Please enter your details below to login.{/i18n}</p> | 31 | <p class="descriptiveText">{i18n}Please enter your details below to login.{/i18n}</p> |
| 32 | {else} | 32 | {else} |
| 33 | - <div class="ktErrorMessage"><span>{$errorMessage|sanitize}</span></div> | 33 | + <div class="ktErrorMessage"><span> |
| 34 | + {if ($errorMessage == $errorMessageConfirm)} | ||
| 35 | + {$errorMessage} | ||
| 36 | + {else} | ||
| 37 | + {$errorMessage|sanitize} | ||
| 38 | + {/if} | ||
| 39 | + </span></div> | ||
| 34 | {/if} | 40 | {/if} |
| 35 | <label for="username">{i18n}Username{/i18n}</label> | 41 | <label for="username">{i18n}Username{/i18n}</label> |
| 36 | <input type="text" id="username" name="username"/> | 42 | <input type="text" id="username" name="username"/> |
| @@ -54,9 +60,15 @@ | @@ -54,9 +60,15 @@ | ||
| 54 | </div> | 60 | </div> |
| 55 | {/if} | 61 | {/if} |
| 56 | <p class="descriptiveText version"> | 62 | <p class="descriptiveText version"> |
| 57 | - {i18n}Access to this service is subject to the KnowledgeTreeLive <a href="http://www.knowledgetree.com/about/legal/live">Terms and Conditions</a> of use.{/i18n}<br/> | ||
| 58 | - {i18n}© 2007 <a href="http://www.knowledgetree.com/">The Jam Warehouse Software (Pty) Ltd.</a> All Rights Reserved{/i18n} | ||
| 59 | - </p> | 63 | + {i18n arg_appname="$appname"}#appname# Version{/i18n} {$versionName}<br/> |
| 64 | + {i18n}<a href="http://www.knowledgetree.com/">Document Management Software</a>{/i18n}<br> | ||
| 65 | + {i18n}© 2007 <a href="http://www.knowledgetree.com/">The Jam Warehouse Software (Pty) Ltd.</a>{/i18n}<br><br> | ||
| 66 | + {if ($smallVersion == 'OSS')} | ||
| 67 | + {i18n}This program is free software and published under the <a href=" http://www.gnu.org/licenses/">GNU General Public License version 3</a>{/i18n}<br> | ||
| 68 | + {else} | ||
| 69 | + {i18n}All rights reserved.{/i18n}<br> | ||
| 70 | + {/if} | ||
| 71 | + </p> | ||
| 60 | <div id="bottomspacer"></div> | 72 | <div id="bottomspacer"></div> |
| 61 | <div class="floatClear"></div> | 73 | <div class="floatClear"></div> |
| 62 | </div> | 74 | </div> |
templates/ktcore/manage_permissions.smarty
| 1 | +{literal} | ||
| 2 | +<script type="text/javascript"> | ||
| 3 | + function populateField(value, key){ | ||
| 4 | + var field = document.getElementById(key); | ||
| 5 | + field.value = value; | ||
| 6 | + } | ||
| 7 | +</script> | ||
| 8 | +{/literal} | ||
| 1 | <h2>{i18n}Existing permissions{/i18n}</h2> | 9 | <h2>{i18n}Existing permissions{/i18n}</h2> |
| 2 | 10 | ||
| 3 | <p class="descriptiveText">{i18n}Permissions are descriptors used to ascertain whether groups of users have access to certain functionality. The built-in permissions below facilitate the default functionality of the DMS and can't be changed. Plugin developers may choose to add additional permissions below that manage access to their plugins functionality.{/i18n}</p> | 11 | <p class="descriptiveText">{i18n}Permissions are descriptors used to ascertain whether groups of users have access to certain functionality. The built-in permissions below facilitate the default functionality of the DMS and can't be changed. Plugin developers may choose to add additional permissions below that manage access to their plugins functionality.{/i18n}</p> |
| @@ -54,4 +62,13 @@ class="ktAction ktDelete">{i18n}Delete Permission{/i18n}</a> | @@ -54,4 +62,13 @@ class="ktAction ktDelete">{i18n}Delete Permission{/i18n}</a> | ||
| 54 | </tr> | 62 | </tr> |
| 55 | { /foreach } | 63 | { /foreach } |
| 56 | </table> | 64 | </table> |
| 57 | - | 65 | +{if $context->sNameVal != ''} |
| 66 | +<script type="text/javascript"> | ||
| 67 | + populateField("{$context->sNameVal}", "name"); | ||
| 68 | +</script> | ||
| 69 | +{/if} | ||
| 70 | +{if $context->sHumanNameVal != ''} | ||
| 71 | +<script type="text/javascript"> | ||
| 72 | + populateField("{$context->sHumanNameVal}", "human_name"); | ||
| 73 | +</script> | ||
| 74 | +{/if} | ||
| 58 | \ No newline at end of file | 75 | \ No newline at end of file |
templates/ktcore/search2/adv_query_builder.smarty
| @@ -219,7 +219,7 @@ function initInt(groupid, fid) | @@ -219,7 +219,7 @@ function initInt(groupid, fid) | ||
| 219 | 219 | ||
| 220 | var nf = new Ext.form.NumberField( {allowNegative: false, decimalPrecision : 0, name: startname}); | 220 | var nf = new Ext.form.NumberField( {allowNegative: false, decimalPrecision : 0, name: startname}); |
| 221 | nf.render(startname); | 221 | nf.render(startname); |
| 222 | - var nf2 = new Ext.form.NumberField( {allowNegative: false, decimalPrecision : 0, name: startname}); | 222 | + var nf2 = new Ext.form.NumberField( {allowNegative: false, decimalPrecision : 0, name: endname}); |
| 223 | nf2.render(endname); | 223 | nf2.render(endname); |
| 224 | } | 224 | } |
| 225 | 225 | ||
| @@ -721,6 +721,7 @@ function buildExpression() | @@ -721,6 +721,7 @@ function buildExpression() | ||
| 721 | var expr = expr = fieldname + ' ' + fieldop + ' "' + start.value + '"'; | 721 | var expr = expr = fieldname + ' ' + fieldop + ' "' + start.value + '"'; |
| 722 | switch (fieldop) | 722 | switch (fieldop) |
| 723 | { | 723 | { |
| 724 | + case 'between': | ||
| 724 | case 'BETWEEN': | 725 | case 'BETWEEN': |
| 725 | expr += ' AND "' + end.value + '"'; | 726 | expr += ' AND "' + end.value + '"'; |
| 726 | break; | 727 | break; |
templates/ktcore/search2/lucene_statistics.smarty
| 1 | -<P> | ||
| 2 | -{i18n}This dashlet provides some basic statistics from the KnowledgeTree Document Indexer.{/i18n} | ||
| 3 | -<P> | 1 | +<html> |
| 2 | +<head> | ||
| 3 | +{literal} | ||
| 4 | +<script type="text/javascript"> | ||
| 4 | 5 | ||
| 6 | +function tog1(){ | ||
| 7 | + | ||
| 8 | + var toggled = document.getElementById('expand'); | ||
| 9 | + var pImage = document.getElementById('id'); | ||
| 10 | + var mImage = document.getElementById('ie'); | ||
| 11 | + if(pImage.style.display == 'block'){ | ||
| 12 | + pImage.style.display = 'none'; | ||
| 13 | + mImage.style.display = 'block'; | ||
| 14 | + }else{ | ||
| 15 | + pImage.style.display = 'block'; | ||
| 16 | + mImage.style.display = 'none'; | ||
| 17 | + } | ||
| 18 | + if(toggled.style.display == 'none'){ | ||
| 19 | + toggled.style.display = 'block'; | ||
| 20 | + }else{ | ||
| 21 | + toggled.style.display = 'none'; | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | +} | ||
| 25 | + | ||
| 26 | +function tog2(){ | ||
| 27 | + | ||
| 28 | + var toggle = document.getElementById('exp'); | ||
| 29 | + var plusImage = document.getElementById('imgd'); | ||
| 30 | + var minusImage = document.getElementById('imge'); | ||
| 31 | + if(plusImage.style.display == 'block'){ | ||
| 32 | + plusImage.style.display = 'none'; | ||
| 33 | + minusImage.style.display = 'block'; | ||
| 34 | + }else{ | ||
| 35 | + plusImage.style.display = 'block'; | ||
| 36 | + minusImage.style.display = 'none'; | ||
| 37 | + } | ||
| 38 | + if(toggle.style.display == 'none'){ | ||
| 39 | + toggle.style.display = 'block'; | ||
| 40 | + }else{ | ||
| 41 | + toggle.style.display = 'none'; | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | +} | ||
| 45 | + | ||
| 46 | +</script> | ||
| 47 | +{/literal} | ||
| 48 | +</head> | ||
| 49 | + | ||
| 50 | +<body> | ||
| 5 | <table> | 51 | <table> |
| 6 | -<tr><td>{i18n}Last optimisation date:{/i18n}</td><td>{$stats.optimisationDate}</td></tr> | ||
| 7 | -<tr><td>{i18n}Period since last optimisation:{/i18n}</td><td>{$stats.optimisationPeriod}</td></tr> | ||
| 8 | -<tr><td>{i18n}Last indexing date:{/i18n}</td><td>{$stats.indexingDate}</td></tr> | ||
| 9 | -<tr><td>{i18n}Period since last indexing:{/i18n}</td><td>{$stats.indexingPeriod}</td></tr> | ||
| 10 | -<tr><td>{i18n}Total documents in repository:{/i18n}</td><td>{$stats.docsInRepository}</td></tr> | ||
| 11 | -<tr><td>{i18n}Documents in index:{/i18n}</td><td>{$stats.docsInIndex}</td></tr> | ||
| 12 | -<tr><td>{i18n}Documents in indexing queue:{/i18n}</td><td>{$stats.docsInQueue}</td></tr> | ||
| 13 | -<tr><td>{i18n}Indexing coverage:{/i18n}</td><td>{$stats.indexingCoverage}</td></tr> | ||
| 14 | -<tr><td>{i18n}Queue coverage:{/i18n}</td><td>{$stats.queueCoverage}</td></tr> | 52 | +<tr><td width="495px">{i18n}Last Optimization Date:{/i18n}</td><td>{$stats.optimisationDate}</td></tr> |
| 53 | +<tr></tr> | ||
| 54 | +<tr><td>{i18n}Period Since Last Optimization:{/i18n}</td><td>{$stats.optimisationPeriod}</td></tr> | ||
| 55 | +<tr><td>{i18n}Last Indexing Date:{/i18n}</td><td>{$stats.indexingDate}</td></tr> | ||
| 56 | +<tr><td>{i18n}Period Since Last Indexing:{/i18n}</td><td>{$stats.indexingPeriod}</td></tr> | ||
| 57 | +<tr><td>{i18n}Total # Documents in Repository:{/i18n}</td><td>{$stats.docsInRepository}</td></tr> | ||
| 58 | +<tr><td>{i18n}Documents Indexed:{/i18n}</td><td>{$stats.docsInIndex}</td></tr> | ||
| 59 | +<tr><td>{i18n}Documents in Indexing Queue:{/i18n}</td><td>{$stats.docsInQueue}</td></tr> | ||
| 60 | +<tr><td><span onclick="tog1();"> | ||
| 61 | +<p id="id"> | ||
| 62 | +<img src="{$rootUrl}/resources/graphics/bullet_toggle_plus.png" style="cursor: pointer;"/> | ||
| 63 | +Index Coverage: | ||
| 64 | +</p> | ||
| 65 | +<p id="ie"> | ||
| 66 | +<img src="{$rootUrl}/resources/graphics/bullet_toggle_minus.png" style="cursor: pointer;"/> | ||
| 67 | +Index Coverage: | ||
| 68 | +</p> | ||
| 69 | +</span> | ||
| 70 | +<div id="expand" style="display: none;"> | ||
| 71 | +<i>{i18n}Indexing coverage percentage may vary from total - not all documents contain text.{/i18n}</i> | ||
| 72 | +<br/> | ||
| 73 | +</div></td><td>{$stats.indexingCoverage}</td></tr> | ||
| 74 | + | ||
| 75 | + | ||
| 76 | +<tr><td><span onclick="tog2();"> | ||
| 77 | +<p id="imgd"> | ||
| 78 | +<img src="{$rootUrl}/resources/graphics/bullet_toggle_plus.png" style="cursor: pointer;"/> | ||
| 79 | +Queue Coverage: | ||
| 80 | +</p> | ||
| 81 | +<p id="imge"> | ||
| 82 | +<img src="{$rootUrl}/resources/graphics/bullet_toggle_minus.png" style="cursor: pointer;"/> | ||
| 83 | +Queue Coverage: | ||
| 84 | +</p> | ||
| 85 | +</span> | ||
| 86 | +<div id="exp" style="display: none;"> | ||
| 87 | +<i>{i18n}Queue coverage indicates percentage of documents currently queued for indexing in relation to total repository size{/i18n}</i> | ||
| 88 | +<br/> | ||
| 89 | +</div> | ||
| 90 | +</td><td>{$stats.queueCoverage}</td></tr> | ||
| 91 | + | ||
| 15 | </table> | 92 | </table> |
| 16 | -<b>{i18n}Notes:{/i18n}</b><br> | 93 | + |
| 17 | <table> | 94 | <table> |
| 18 | -<tr><td valign=top>*<td>{i18n}Not all documents contain text. This will explain why the indexing coverage percentage my vary.{/i18n} | ||
| 19 | -<tr><td valign=top>*<td>{i18n}The queue coverage indicates how many documents are in the queue in relation to the repository size.{/i18n} | 95 | + |
| 20 | {if $stats.noOptimisation} | 96 | {if $stats.noOptimisation} |
| 21 | <tr><td valign=top>*<td><i>{i18n}To get the best performance out of Document Indexer, the indexes must be optimised periodically. This is managed by a background task.{/i18n} | 97 | <tr><td valign=top>*<td><i>{i18n}To get the best performance out of Document Indexer, the indexes must be optimised periodically. This is managed by a background task.{/i18n} |
| 22 | {/if} | 98 | {/if} |
| 23 | </table> | 99 | </table> |
| 24 | <table width="100%"> | 100 | <table width="100%"> |
| 25 | <tr><td colspan=2 align=right><a href="/search2.php?action=refreshLuceneStats" align=right>{i18n}Refresh{/i18n}</a></tr> | 101 | <tr><td colspan=2 align=right><a href="/search2.php?action=refreshLuceneStats" align=right>{i18n}Refresh{/i18n}</a></tr> |
| 26 | -</table> | ||
| 27 | \ No newline at end of file | 102 | \ No newline at end of file |
| 103 | +</table> | ||
| 104 | + | ||
| 105 | +<script type="text/javascript"> | ||
| 106 | +var plusImage = document.getElementById('imgd'); | ||
| 107 | +var minusImage = document.getElementById('imge'); | ||
| 108 | +plusImage.style.display = 'block'; | ||
| 109 | +minusImage.style.display = 'none'; | ||
| 110 | + | ||
| 111 | +var pImage = document.getElementById('id'); | ||
| 112 | +var mImage = document.getElementById('ie'); | ||
| 113 | +pImage.style.display = 'block'; | ||
| 114 | +mImage.style.display = 'none'; | ||
| 115 | +</script> | ||
| 116 | + | ||
| 117 | +</body> | ||
| 118 | +</html> | ||
| 28 | \ No newline at end of file | 119 | \ No newline at end of file |