Commit a69452c47795f045312b95dc09a7b105adeaa0db
Merge branch 'edge' of git@github.com:ktgit/knowledgetree into edge
Showing
10 changed files
with
195 additions
and
21 deletions
ktwebservice/KTDownloadManager.inc.php
| ... | ... | @@ -197,6 +197,66 @@ class KTDownloadManager |
| 197 | 197 | |
| 198 | 198 | return true; |
| 199 | 199 | } |
| 200 | + | |
| 201 | + function multipart_download($document_id, $hash, $version = null, $apptype = 'ws', $chunkSize = NULL, $part = 0) { | |
| 202 | + $oConfig =& KTConfig::getSingleton(); | |
| 203 | + | |
| 204 | + $sql = "SELECT 1 FROM download_files WHERE hash=? AND session=? AND document_id=?"; | |
| 205 | + $rows = DBUtil::getResultArray ( array ($sql, array ($hash, $this->session, $document_id ) ) ); | |
| 206 | + if (PEAR::isError ( $rows )) { | |
| 207 | + return $rows; | |
| 208 | + } | |
| 209 | + | |
| 210 | + if (count ( $rows ) == 0) { | |
| 211 | + return new PEAR_Error ( 'Invalid session.' ); | |
| 212 | + } | |
| 213 | + | |
| 214 | + // If document is being downloaded by an external user bypass the session checking | |
| 215 | + $check = strstr ( $this->session, 'ktext_' . $document_id ); | |
| 216 | + if ($check == 0 && $check !== false) { | |
| 217 | + // Use external download function | |
| 218 | + return $this->download_ext ( $document_id, $hash, $version = null ); | |
| 219 | + } | |
| 220 | + | |
| 221 | + $storage = & KTStorageManagerUtil::getSingleton (); | |
| 222 | + | |
| 223 | + $ktapi = &new KTAPI ( ); | |
| 224 | + $res = $ktapi->get_active_session ( $this->session, null, $apptype ); | |
| 225 | + if (PEAR::isError ( $res )) { | |
| 226 | + return $res; | |
| 227 | + } | |
| 228 | + | |
| 229 | + $document = $ktapi->get_document_by_id ( $document_id ); | |
| 230 | + if (PEAR::isError ( $document )) { | |
| 231 | + return $document; | |
| 232 | + } | |
| 233 | + | |
| 234 | + if (! empty ( $version )) { | |
| 235 | + $version = KTDocumentContentVersion::get ( $version ); | |
| 236 | + $res = $storage->downloadVersion ( $document->document, $version ); | |
| 237 | + } else { | |
| 238 | + $res = $storage->download ( $document->document ); | |
| 239 | + } | |
| 240 | + if (PEAR::isError ( $res )) { | |
| 241 | + return $res; | |
| 242 | + } | |
| 243 | + | |
| 244 | + // Set Default Chunk Size (in KB) | |
| 245 | + $chunkSize=(int)$chunkSize; | |
| 246 | + if($chunkSize<1024)$chunkSize=1024; | |
| 247 | + | |
| 248 | + //Make sure part is set | |
| 249 | + $part=(int)$part; | |
| 250 | + | |
| 251 | + $fileSize=$document->getFileSize(); | |
| 252 | + $fileName=$document->getFileName(); | |
| 253 | + $path=$oConfig->get('urls/documentRoot').'/'.$document->getStoragePath(); | |
| 254 | + | |
| 255 | +// $sql = "DELETE FROM download_files WHERE hash='$hash' AND session='$this->session' AND document_id=$document_id"; | |
| 256 | +// $result = DBUtil::runQuery ( $sql ); | |
| 257 | + | |
| 258 | + return true; | |
| 259 | + } | |
| 200 | 260 | |
| 201 | 261 | function download_ext($document_id, $hash, $version = null) |
| 202 | 262 | { | ... | ... |
plugins/ktcore/KTValidators.php
| ... | ... | @@ -589,8 +589,17 @@ class KTDateValidator extends KTValidator { |
| 589 | 589 | $results = array(); |
| 590 | 590 | $errors = array(); |
| 591 | 591 | |
| 592 | - // very simple if we're required and not present, fail | |
| 592 | + // very simple if we're required and not present, fail | |
| 593 | 593 | // otherwise, its ok. |
| 594 | + $pMetaKey = array_keys($data); | |
| 595 | + $fieldId = str_replace('metadata_', '', $pMetaKey); | |
| 596 | + $oField = new DocumentField(); | |
| 597 | + $oField->load($fieldId); | |
| 598 | + | |
| 599 | + if (!$oField->getIsMandatory()) { | |
| 600 | + return; | |
| 601 | + } | |
| 602 | + | |
| 594 | 603 | $val = KTUtil::arrayGet($data, $this->sInputVariable); |
| 595 | 604 | |
| 596 | 605 | if ($this->bTrim) { | ... | ... |
plugins/multiselect/BulkImport.php
| ... | ... | @@ -106,6 +106,22 @@ class InetBulkImportFolderMultiSelectAction extends KTFolderAction { |
| 106 | 106 | function getBulkImportForm() { |
| 107 | 107 | $this->oPage->setBreadcrumbDetails(_kt("bulk import")); |
| 108 | 108 | |
| 109 | + //Adding the required Bulk Upload javascript includes | |
| 110 | + $aJavascript[] = 'resources/js/taillog.js'; | |
| 111 | + $aJavascript[] = 'resources/js/conditional_usage.js'; | |
| 112 | + $aJavascript[] = 'resources/js/kt_bulkupload.js'; | |
| 113 | + | |
| 114 | + //Loading the widget js libraries to support dynamic "Ajax Loaded" widget rendering | |
| 115 | + //FIXME: The widgets can support this via dynamic call to place libs in the head if they aren't loaded | |
| 116 | + // jQuery can do this but need time to implement/test. | |
| 117 | + | |
| 118 | + $aJavascript[] = 'thirdpartyjs/jquery/jquery-1.3.2.js'; | |
| 119 | + $aJavascript[] = 'thirdpartyjs/tinymce/jscripts/tiny_mce/tiny_mce.js'; | |
| 120 | + $aJavascript[] = 'resources/js/kt_tinymce_init.js'; | |
| 121 | + $aJavascript[] = 'thirdpartyjs/tinymce/jscripts/tiny_mce/jquery.tinymce.js'; | |
| 122 | + | |
| 123 | + $this->oPage->requireJSResources($aJavascript); | |
| 124 | + | |
| 109 | 125 | $oForm = new KTForm; |
| 110 | 126 | $oForm->setOptions(array( |
| 111 | 127 | 'identifier' => 'ktcore.folder.bulkUpload', |
| ... | ... | @@ -139,22 +155,21 @@ class InetBulkImportFolderMultiSelectAction extends KTFolderAction { |
| 139 | 155 | 'description' => _kt('The path containing the documents to be added to the document management system.'), |
| 140 | 156 | )); |
| 141 | 157 | |
| 142 | - $aTypes = array(); | |
| 143 | - foreach (DocumentType::getListForUserAndFolder($this->oUser, $this->oFolder) as $oDocumentType) { | |
| 144 | - if(!$oDocumentType->getDisabled()) { | |
| 145 | - $aTypes[] = $oDocumentType; | |
| 146 | - } | |
| 147 | - } | |
| 148 | - | |
| 158 | + $aVocab = array('' => _kt('- Please select a document type -')); | |
| 159 | + foreach (DocumentType::getListForUserAndFolder($this->oUser, $this->oFolder) as $oDocumentType) { | |
| 160 | + if(!$oDocumentType->getDisabled()) { | |
| 161 | + $aVocab[$oDocumentType->getId()] = $oDocumentType->getName(); | |
| 162 | + } | |
| 163 | + } | |
| 164 | + | |
| 149 | 165 | //Adding document type lookup widget |
| 150 | - $widgets[] = $oWF->get('ktcore.widgets.entityselection',array( | |
| 166 | + $widgets[] = $oWF->get('ktcore.widgets.selection',array( | |
| 151 | 167 | 'label' => _kt('Document Type'), |
| 152 | 168 | 'id' => 'add-document-type', |
| 153 | 169 | 'description' => _kt('Document Types, defined by the administrator, are used to categorise documents. Please select a Document Type from the list below.'), |
| 154 | 170 | 'name' => 'fDocumentTypeId', |
| 155 | 171 | 'required' => true, |
| 156 | - 'vocab' => $aTypes, | |
| 157 | - 'initial_string' => _kt('- Please select a document type -'), | |
| 172 | + 'vocab' => $aVocab, | |
| 158 | 173 | 'id_method' => 'getId', |
| 159 | 174 | 'label_method' => 'getName', |
| 160 | 175 | 'simple_select' => false, |
| ... | ... | @@ -172,16 +187,22 @@ class InetBulkImportFolderMultiSelectAction extends KTFolderAction { |
| 172 | 187 | )); |
| 173 | 188 | |
| 174 | 189 | $oFReg =& KTFieldsetRegistry::getSingleton(); |
| 175 | - | |
| 190 | + | |
| 176 | 191 | $activesets = KTFieldset::getGenericFieldsets(); |
| 177 | 192 | foreach ($activesets as $oFieldset) { |
| 178 | 193 | $widgets = kt_array_merge($widgets, $oFReg->widgetsForFieldset($oFieldset, 'fieldset_' . $oFieldset->getId(), $this->oDocument)); |
| 179 | 194 | $validators = kt_array_merge($validators, $oFReg->validatorsForFieldset($oFieldset, 'fieldset_' . $oFieldset->getId(), $this->oDocument)); |
| 180 | 195 | } |
| 181 | - | |
| 196 | + | |
| 197 | + //Adding the type_metadata_fields layer to be updated via ajax for non generic metadata fieldsets | |
| 198 | + $widgets[] = $oWF->get('ktcore.widgets.layer',array( | |
| 199 | + 'value' => '', | |
| 200 | + 'id' => 'type_metadata_fields', | |
| 201 | + )); | |
| 202 | + | |
| 182 | 203 | $oForm->setWidgets($widgets); |
| 183 | 204 | $oForm->setValidators($validators); |
| 184 | - | |
| 205 | + | |
| 185 | 206 | // Implement an electronic signature for accessing the admin section, it will appear every 10 minutes |
| 186 | 207 | global $default; |
| 187 | 208 | $iFolderId = $this->oFolder->getId(); | ... | ... |
setup/migrate/migrateWizard.php
| ... | ... | @@ -261,7 +261,7 @@ class MigrateWizard { |
| 261 | 261 | } |
| 262 | 262 | } else { |
| 263 | 263 | // TODO: Die gracefully |
| 264 | - $this->util->error("System has been migrated <a href='../../login.php' class='back' style='width:80px;float:none' back button_next>Goto Login</a>"); | |
| 264 | + $this->util->error("System has been migrated <a href='../../login.php' class='back' style='width:90px;float:none' back button_next>Goto Login</a>"); | |
| 265 | 265 | } |
| 266 | 266 | } |
| 267 | 267 | } | ... | ... |
setup/upgrade/templates/complete.tpl
| ... | ... | @@ -9,5 +9,5 @@ |
| 9 | 9 | Your database has been upgraded to <?php echo $default->systemVersion; ?> |
| 10 | 10 | </div> |
| 11 | 11 | </div> |
| 12 | - <a href="../../" class="back button_next" style="width:80px;" onclick="javascript:{w.clearSessions();}">Goto Login</a> | |
| 12 | + <a href="../../" class="back button_next" style="width:90px;" onclick="javascript:{w.clearSessions();}">Goto Login</a> | |
| 13 | 13 | </form> |
| 14 | 14 | \ No newline at end of file | ... | ... |
setup/wizard/installWizard.php
| ... | ... | @@ -296,7 +296,7 @@ class InstallWizard { |
| 296 | 296 | } |
| 297 | 297 | } else { |
| 298 | 298 | // TODO: Die gracefully |
| 299 | - $this->util->error("System has been installed <a href='../../login.php' class='back' style='width:80px;float:none' class='back button_next'>Goto Login</a>"); | |
| 299 | + $this->util->error("System has been installed <a href='../../login.php' class='back' style='width:90px;float:none' class='back button_next'>Goto Login</a>"); | |
| 300 | 300 | } |
| 301 | 301 | } |
| 302 | 302 | } | ... | ... |
setup/wizard/resources/css/wizard.css
setup/wizard/templates/complete.tpl
| ... | ... | @@ -136,7 +136,7 @@ |
| 136 | 136 | <?php if($migrate_check) { ?> |
| 137 | 137 | <a href="../upgrade" class="back button_next" style="width:190px;" onclick="javascript:{w.clearSessions();}">Goto Database Upgrade</a> |
| 138 | 138 | <?php } else { ?> |
| 139 | - <a href="../../login.php?redirect=<?php echo $redirect; ?>" class="back button_next" style="width:80px;" onclick="javascript:{w.clearSessions();}">Goto Login</a> | |
| 139 | + <a href="../../login.php?redirect=<?php echo $redirect; ?>" class="back button_next" style="width:90px;" onclick="javascript:{w.clearSessions();}">Goto Login</a> | |
| 140 | 140 | <?php } ?> |
| 141 | 141 | <?php |
| 142 | 142 | if ($install_environment == 'Zend') { | ... | ... |
webservice/clienttools/services/0.2/kt.php
| ... | ... | @@ -461,7 +461,7 @@ class kt extends client_service { |
| 461 | 461 | if (PEAR::isError($document)) |
| 462 | 462 | { |
| 463 | 463 | $response['message']=$document->getMessage(); |
| 464 | - $this->addDebug("download_document - cannot get $document_id - " . $document->getMessage(), $session_id); | |
| 464 | + //$this->addDebug("download_document - cannot get $document_id - " . $document->getMessage(), $session_id); | |
| 465 | 465 | |
| 466 | 466 | // $this->setResponse(new SOAP_Value('$this->response=',"{urn:$this->namespace}kt_response", $response)); |
| 467 | 467 | $this->setResponse($response); |
| ... | ... | @@ -900,7 +900,7 @@ class kt extends client_service { |
| 900 | 900 | $document=$kt->get_document_by_id($document_id); |
| 901 | 901 | |
| 902 | 902 | if(isset($special['__title'])) { |
| 903 | - $this->debug("Renaming to {$special['__title']}"); | |
| 903 | + $this->addDebug("Renaming to {$special['__title']}"); | |
| 904 | 904 | $res=$document->rename($special['__title']); |
| 905 | 905 | } |
| 906 | 906 | } | ... | ... |
webservice/clienttools/services/mdownload.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * | |
| 5 | + * This does the download of a file based on the download_files table. | |
| 6 | + * | |
| 7 | + * KnowledgeTree Community Edition | |
| 8 | + * Document Management Made Simple | |
| 9 | + * Copyright (C) 2008, 2009 KnowledgeTree Inc. | |
| 10 | + * Portions copyright The Jam Warehouse Software (Pty) Limited | |
| 11 | + * | |
| 12 | + * This program is free software; you can redistribute it and/or modify it under | |
| 13 | + * the terms of the GNU General Public License version 3 as published by the | |
| 14 | + * Free Software Foundation. | |
| 15 | + * | |
| 16 | + * This program is distributed in the hope that it will be useful, but WITHOUT | |
| 17 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 18 | + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
| 19 | + * details. | |
| 20 | + * | |
| 21 | + * You should have received a copy of the GNU General Public License | |
| 22 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 23 | + * | |
| 24 | + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | |
| 25 | + * California 94120-7775, or email info@knowledgetree.com. | |
| 26 | + * | |
| 27 | + * The interactive user interfaces in modified source and object code versions | |
| 28 | + * of this program must display Appropriate Legal Notices, as required under | |
| 29 | + * Section 5 of the GNU General Public License version 3. | |
| 30 | + * | |
| 31 | + * In accordance with Section 7(b) of the GNU General Public License version 3, | |
| 32 | + * these Appropriate Legal Notices must retain the display of the "Powered by | |
| 33 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 34 | + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | |
| 35 | + * must display the words "Powered by KnowledgeTree" and retain the original | |
| 36 | + * copyright notice. | |
| 37 | + * Contributor( s): ______________________________________ | |
| 38 | + * | |
| 39 | + */ | |
| 40 | + | |
| 41 | +if (!array_key_exists('code',$_GET)) | |
| 42 | +{ | |
| 43 | + $msg = urlencode('Code not specified.'); | |
| 44 | + print "status_code=1&msg=$msg"; | |
| 45 | + exit; | |
| 46 | +} | |
| 47 | + | |
| 48 | +$hash = $_GET['code']; | |
| 49 | + | |
| 50 | +if (!array_key_exists('d',$_GET)) | |
| 51 | +{ | |
| 52 | + $msg = urlencode('Document not specified.'); | |
| 53 | + print "status_code=2&msg=$msg"; | |
| 54 | + exit; | |
| 55 | +} | |
| 56 | + | |
| 57 | +$document_id = $_GET['d']; | |
| 58 | + | |
| 59 | +if (!array_key_exists('u',$_GET)) | |
| 60 | +{ | |
| 61 | + $msg = urlencode('Session not specified.'); | |
| 62 | + print "status_code=3&msg=$msg"; | |
| 63 | + exit; | |
| 64 | +} | |
| 65 | + | |
| 66 | +$session = $_GET['u']; | |
| 67 | +$apptype = (isset($_GET['apptype'])) ? $_GET['apptype'] : 'ws'; | |
| 68 | + | |
| 69 | +require_once('../../../config/dmsDefaults.php'); | |
| 70 | +require_once('../../../ktapi/ktapi.inc.php'); | |
| 71 | +require_once('../../../ktwebservice/KTDownloadManager.inc.php'); | |
| 72 | + | |
| 73 | +$download_manager = new KTDownloadManager(); | |
| 74 | +$download_manager->set_session($session); | |
| 75 | + | |
| 76 | +$response = $download_manager->multipart_download($document_id, $hash, null, $apptype,1024,$_GET['part']); | |
| 77 | +if (PEAR::isError($response)) | |
| 78 | +{ | |
| 79 | + $msg = urlencode($response->getMessage()); | |
| 80 | + print "status_code=4&msg=$msg:".$_GET["u"].":".$_GET["d"].":".$_GET["code"].":".$_GET["apptype"].":"; | |
| 81 | + exit; | |
| 82 | +} | |
| 83 | + | |
| 84 | +?> | |
| 0 | 85 | \ No newline at end of file | ... | ... |