コード例 #1
0
ファイル: testDocument.php プロジェクト: 5haman/knowledgetree
 function &_addFile($sFileName, $aOptions = null)
 {
     if (!is_array($aOptions)) {
         $aOptions = array();
     }
     $oDocument =& KTDocumentUtil::add($this->oFolder, $sFileName, $this->oUser, $aOptions);
     return $oDocument;
 }
コード例 #2
0
ファイル: reindex.php プロジェクト: 5haman/knowledgetree
 function do_main()
 {
     $aDocuments = Document::getList();
     $s = '';
     foreach ($aDocuments as $oDocument) {
         $this->startTransaction();
         KTDocumentUtil::reindexDocument($oDocument);
         $s .= $oDocument->getName() . '<br />';
         $this->commitTransaction();
     }
     return $s;
 }
コード例 #3
0
 function testBreadcrumbsForDocument()
 {
     $oFolder =& KTFolderUtil::add($this->oFolder, 'testBreadcrumbsForDocument', $this->oUser);
     $oDocument =& KTDocumentUtil::add($oFolder, 'testBreadcrumbsForDocument.txt', $this->oUser, array());
     $aBreadcrumbs =& KTBrowseUtil::breadcrumbsForDocument($oDocument, array('final' => true));
     $this->assertEqual($this->_getId($aBreadcrumbs[0]['url']), 1);
     $this->assertEqual($aBreadcrumbs[0]['name'], 'Folders');
     $this->assertEqual($this->_getId($aBreadcrumbs[1]['url']), $this->oFolder->getId());
     $this->assertEqual($aBreadcrumbs[1]['name'], $this->oFolder->getName());
     $this->assertEqual($this->_getId($aBreadcrumbs[2]['url']), $oFolder->getId());
     $this->assertEqual($aBreadcrumbs[2]['name'], $oFolder->getName());
     $this->assertNull($aBreadcrumbs[3]['url']);
     $this->assertEqual($aBreadcrumbs[3]['name'], $oDocument->getName());
     $aBreadcrumbs =& KTBrowseUtil::breadcrumbsForDocument($oDocument, array('final' => false));
     $this->assertEqual($this->_getId($aBreadcrumbs[0]['url']), 1);
     $this->assertEqual($aBreadcrumbs[0]['name'], 'Folders');
     $this->assertEqual($this->_getId($aBreadcrumbs[1]['url']), $this->oFolder->getId());
     $this->assertEqual($aBreadcrumbs[1]['name'], $this->oFolder->getName());
     $this->assertEqual($this->_getId($aBreadcrumbs[2]['url']), $oFolder->getId());
     $this->assertEqual($aBreadcrumbs[2]['name'], $oFolder->getName());
     $this->assertEqual($this->_getId($aBreadcrumbs[3]['url']), $oDocument->getId());
     $this->assertEqual($aBreadcrumbs[3]['name'], $oDocument->getName());
 }
コード例 #4
0
 function _importdocument($oFolder, $sPath)
 {
     $aInfo = $this->oStorage->getDocumentInfo($sPath);
     $sTmpFileName = sprintf("%s/%s", $this->oStorage->sBasePath, $sPath);
     if (PEAR::isError($aInfo)) {
         return $aInfo;
     }
     // need to check both of these.
     /*if (KTDocumentUtil::nameExists($oFolder, utf8_encode(basename($sPath)))) {
           $_SESSION['KTErrorMessage'][] = sprintf(_kt("The document %s is already present in %s.  Ignoring."), utf8_encode(basename($sPath)), $oFolder->getName());
           $oDocument =& Document::getByNameAndFolder(utf8_encode(basename($sPath)), KTUtil::getId($oFolder));
           return $oDocument;
       } else if (KTDocumentUtil::fileExists($oFolder, utf8_encode(basename($sPath)))) {
           $_SESSION['KTErrorMessage'][] = sprintf(_kt("The document %s is already present in %s.  Ignoring."), utf8_encode(basename($sPath)), $oFolder->getName());
           $oDocument =& Document::getByFilenameAndFolder(utf8_encode(basename($sPath)), KTUtil::getId($oFolder));
           return $oDocument;
       }*/
     // else
     $aOptions = array('temp_file' => $sTmpFileName, 'metadata' => $this->aMetadata, 'documenttype' => $this->oDocumentType);
     $aOptions = array_merge($aOptions, $this->aOptions);
     $sPath = basename($sPath);
     $sPath = $this->is_utf8($sPath) ? $sPath : utf8_encode($sPath);
     $oDocument =& KTDocumentUtil::add($oFolder, $sPath, $this->oUser, $aOptions, true);
     return $oDocument;
 }
コード例 #5
0
 function performTransition($oDocument, $oUser)
 {
     $iFolderId = KTUtil::arrayGet($this->aConfig, 'folder_id');
     $oToFolder = Folder::get($iFolderId);
     if (PEAR::isError($oFolder)) {
         if ($this->isCopy) {
             return PEAR::raiseError(_kt('The folder to which this document should be copied does not exist.  Cancelling the transition - please contact a system administrator.'));
         } else {
             return PEAR::raiseError(_kt('The folder to which this document should be moved does not exist.  Cancelling the transition - please contact a system administrator.'));
         }
     }
     if ($this->isCopy) {
         return KTDocumentUtil::copy($oDocument, $oToFolder);
     } else {
         return KTDocumentUtil::move($oDocument, $oToFolder, $oUser);
     }
 }
コード例 #6
0
 function copy($oSrcFolder, $oDestFolder, $oUser, $sReason, $sDestFolderName = NULL, $copyAll = true)
 {
     $sDestFolderName = empty($sDestFolderName) ? $oSrcFolder->getName() : $sDestFolderName;
     if (KTFolderUtil::exists($oDestFolder, $sDestFolderName)) {
         return PEAR::raiseError(_kt("Folder with the same name already exists in the new parent folder"));
     }
     //
     // FIXME the failure cleanup code here needs some serious work.
     //
     $oPerm = KTPermission::getByName('ktcore.permissions.read');
     $oBaseFolderPerm = KTPermission::getByName('ktcore.permissions.addFolder');
     if (!KTPermissionUtil::userHasPermissionOnItem($oUser, $oBaseFolderPerm, $oDestFolder)) {
         return PEAR::raiseError(_kt('You are not allowed to create folders in the destination.'));
     }
     // Check if the source folder inherits its permissions
     // Get source PO id and its parent PO id
     $iSrcPoId = $oSrcFolder->getPermissionObjectID();
     $oSrcParent = Folder::get($oSrcFolder->getParentID());
     $iSrcParentPoId = $oSrcParent->getPermissionObjectID();
     // If the folder defines its own permissions then we copy the permission object
     // If the source folder inherits permissions we must change it to inherit from the new parent folder
     $bInheritPermissions = false;
     if ($iSrcPoId == $iSrcParentPoId) {
         $bInheritPermissions = true;
     }
     $aFolderIds = array();
     // of oFolder
     $aDocuments = array();
     // of oDocument
     $aFailedDocuments = array();
     // of String
     $aFailedFolders = array();
     // of String
     $aRemainingFolders = array($oSrcFolder->getId());
     DBUtil::startTransaction();
     while (!empty($aRemainingFolders) && $copyAll) {
         $iFolderId = array_pop($aRemainingFolders);
         $oFolder = Folder::get($iFolderId);
         if (PEAR::isError($oFolder) || $oFolder == false) {
             DBUtil::rollback();
             return PEAR::raiseError(sprintf(_kt('Failure resolving child folder with id = %d.'), $iFolderId));
         }
         // don't just stop ... plough on.
         if (KTPermissionUtil::userHasPermissionOnItem($oUser, $oPerm, $oFolder)) {
             $aFolderIds[] = $iFolderId;
         } else {
             $aFailedFolders[] = $oFolder->getName();
         }
         // child documents
         $aChildDocs = Document::getList(array('folder_id = ?', array($iFolderId)));
         foreach ($aChildDocs as $oDoc) {
             if (KTPermissionUtil::userHasPermissionOnItem($oUser, $oPerm, $oDoc)) {
                 $aDocuments[] = $oDoc;
             } else {
                 $aFailedDocuments[] = $oDoc->getName();
             }
         }
         // child folders.
         $aCFIds = Folder::getList(array('parent_id = ?', array($iFolderId)), array('ids' => true));
         $aRemainingFolders = kt_array_merge($aRemainingFolders, $aCFIds);
     }
     if (!empty($aFailedDocuments) || !empty($aFailedFolders)) {
         $sFD = '';
         $sFF = '';
         if (!empty($aFailedDocuments)) {
             $sFD = _kt('Documents: ') . implode(', ', $aFailedDocuments) . '. ';
         }
         if (!empty($aFailedFolders)) {
             $sFF = _kt('Folders: ') . implode(', ', $aFailedFolders) . '.';
         }
         return PEAR::raiseError(_kt('You do not have permission to copy these items. ') . $sFD . $sFF);
     }
     // first we walk the tree, creating in the new location as we go.
     // essentially this is an "ok" pass.
     $oStorage =& KTStorageManagerUtil::getSingleton();
     $aFolderMap = array();
     $sTable = 'folders';
     $sGetQuery = 'SELECT * FROM ' . $sTable . ' WHERE id = ? ';
     $aParams = array($oSrcFolder->getId());
     $aRow = DBUtil::getOneResult(array($sGetQuery, $aParams));
     unset($aRow['id']);
     $aRow['name'] = $sDestFolderName;
     $aRow['description'] = $sDestFolderName;
     $aRow['parent_id'] = $oDestFolder->getId();
     $aRow['parent_folder_ids'] = sprintf('%s,%s', $oDestFolder->getParentFolderIDs(), $oDestFolder->getId());
     $aRow['full_path'] = $oDestFolder->getFullPath() . '/' . $aRow['name'];
     $id = DBUtil::autoInsert($sTable, $aRow);
     if (PEAR::isError($id)) {
         DBUtil::rollback();
         return $id;
     }
     $sSrcFolderId = $oSrcFolder->getId();
     $aFolderMap[$sSrcFolderId]['parent_id'] = $id;
     $aFolderMap[$sSrcFolderId]['parent_folder_ids'] = $aRow['parent_folder_ids'];
     $aFolderMap[$sSrcFolderId]['full_path'] = $aRow['full_path'];
     $aFolderMap[$sSrcFolderId]['name'] = $aRow['name'];
     $oNewBaseFolder = Folder::get($id);
     $res = $oStorage->createFolder($oNewBaseFolder);
     if (PEAR::isError($res)) {
         // it doesn't exist, so rollback and raise..
         DBUtil::rollback();
         return $res;
     }
     $aRemainingFolders = Folder::getList(array('parent_id = ?', array($oSrcFolder->getId())), array('ids' => true));
     while (!empty($aRemainingFolders) && $copyAll) {
         $iFolderId = array_pop($aRemainingFolders);
         $aParams = array($iFolderId);
         $aRow = DBUtil::getOneResult(array($sGetQuery, $aParams));
         unset($aRow['id']);
         // since we are nested, we will have solved the parent first.
         $sPrevParentId = $aRow['parent_id'];
         $aRow['parent_id'] = $aFolderMap[$aRow['parent_id']]['parent_id'];
         $aRow['parent_folder_ids'] = sprintf('%s,%s', $aFolderMap[$sPrevParentId]['parent_folder_ids'], $aRow['parent_id']);
         $aRow['full_path'] = sprintf('%s/%s', $aFolderMap[$sPrevParentId]['full_path'], $aRow['name']);
         $id = DBUtil::autoInsert($sTable, $aRow);
         if (PEAR::isError($id)) {
             $oStorage->removeFolder($oNewBaseFolder);
             DBUtil::rollback();
             return $id;
         }
         $aFolderMap[$iFolderId]['parent_id'] = $id;
         $aFolderMap[$iFolderId]['parent_folder_ids'] = $aRow['parent_folder_ids'];
         $aFolderMap[$iFolderId]['full_path'] = $aRow['full_path'];
         $aFolderMap[$iFolderId]['name'] = $aRow['name'];
         $oNewFolder = Folder::get($id);
         $res = $oStorage->createFolder($oNewFolder);
         if (PEAR::isError($res)) {
             // first delete, then rollback, then fail out.
             $oStorage->removeFolder($oNewBaseFolder);
             DBUtil::rollback();
             return $res;
         }
         $aCFIds = Folder::getList(array('parent_id = ?', array($iFolderId)), array('ids' => true));
         $aRemainingFolders = kt_array_merge($aRemainingFolders, $aCFIds);
     }
     // now we can go ahead.
     foreach ($aDocuments as $oDocument) {
         $oChildDestinationFolder = Folder::get($aFolderMap[$oDocument->getFolderID()]['parent_id']);
         $res = KTDocumentUtil::copy($oDocument, $oChildDestinationFolder);
         if (PEAR::isError($res) || $res === false) {
             $oStorage->removeFolder($oNewBaseFolder);
             DBUtil::rollback();
             return PEAR::raiseError(_kt('Delete Aborted. Unexpected failure to copydocument: ') . $oDocument->getName() . $res->getMessage());
         }
     }
     $sComment = sprintf(_kt("Folder copied from %s to %s"), $oSrcFolder->getFullPath(), $oDestFolder->getFullPath());
     if ($sReason !== null) {
         $sComment .= sprintf(_kt(" (reason: %s)"), $sReason);
     }
     $oTransaction = KTFolderTransaction::createFromArray(array('folderid' => $oFolder->getId(), 'comment' => $sComment, 'transactionNS' => 'ktcore.transactions.copy', 'userid' => $oUser->getId(), 'ip' => Session::getClientIP()));
     // If the folder inherits its permissions then we set it to inherit from the new parent folder and update permissions
     // If it defines its own then copy the permission object over
     if ($bInheritPermissions) {
         $aOptions = array('evenifnotowner' => true);
         KTPermissionUtil::inheritPermissionObject($oNewBaseFolder, $aOptions);
     } else {
         KTPermissionUtil::copyPermissionObject($oNewBaseFolder);
     }
     // and store
     DBUtil::commit();
     return true;
 }
コード例 #7
0
<?php

require_once "../../config/dmsDefaults.php";
require_once KT_LIB_DIR . '/documentmanagement/documentutil.inc.php';
require_once KT_LIB_DIR . '/filelike/fsfilelike.inc.php';
$oDocument =& Document::get(6);
if (PEAR::isError($oDocument)) {
    print "FAILURE\n";
    var_dump($oDocument);
}
$res = KTDocumentUtil::updateSearchableText($oDocument);
if (PEAR::isError($res)) {
    print "FAILURE\n";
    var_dump($res);
    exit(0);
}
コード例 #8
0
 /**
  * COPY method helper for Documents
  *
  * @param $options array   parameter passing array
  * @param $iFolderID int     Folder ID
  * @param $iDocumentID int     Document ID
  * @return string  HTTP status code or false
  */
 function _COPYDocument($options, $iFolderID, $iDocumentID)
 {
     /* ** Ensure that the destination path exists ** */
     if ($options['dest'] == '') {
         $options["dest"] = substr($options["dest_url"], strlen($_SERVER["SCRIPT_NAME"]));
     }
     $this->ktwebdavLog("Entering _COPYDocument. options are " . print_r($options, true), 'info', true);
     /* ** Get the relevant paths. Get the basename of the destination path as the destination filename.
        Check whether the destination path refers to a folder / document. ** */
     $source_path = $options["path"];
     $dest_path = urldecode($options["dest"]);
     $sDestFileName = basename($dest_path);
     list($iDestFolder, $iDestDoc) = $this->_folderOrDocument($dest_path);
     if ($iDestFolder === false) {
         return "409 Conflict - Destination folder does not exist.";
     }
     /* ** Depth must be infinity to copy a document ** */
     if ($options["depth"] != "infinity") {
         // RFC 2518 Section 9.2, last paragraph
         $this->ktwebdavLog("400 Bad request", 'info', true);
         return "400 Bad request - Depth must be 'infinity'.";
     }
     global $default;
     /* ** Get the source folder object.
        If the destination document is null, then the destination is a folder, set the destination filename to empty, continue.
        If the destination document returns an id, then the document exists. Check overwrite.
        If overwrite is true, then check permissions and delete the document, continue.
        If the destination document is false, then continue. ** */
     $oSrcFolder = Folder::get($iFolderID);
     $new = true;
     if (is_null($iDestDoc)) {
         // the dest is a folder
         //			$this->ktwebdavLog("400 Bad request", 'info', true);
         $this->ktwebdavLog("Destination is a folder.", 'info', true);
         $sDestFileName = '';
         //return "400 Bad request - Destination is a Folder";
     } else {
         if ($iDestDoc !== false) {
             // Document exists
             $this->ktwebdavLog("Destination Document exists.", 'info', true);
             $oReplaceDoc = Document::get($iDestDoc);
             if ($options['overwrite'] != 'T') {
                 $this->ktwebdavLog("Overwrite needs to be TRUE.", 'info', true);
                 return "412 Precondition Failed - Destination Document exists. Overwrite needs to be TRUE.";
             }
             $this->ktwebdavLog("Overwrite is TRUE, deleting Destination Document.", 'info', true);
             // Check if the user has permissions to delete this document
             $oPerm =& KTPermission::getByName('ktcore.permissions.delete');
             $oUser =& User::get($this->userID);
             if (!KTPermissionUtil::userHasPermissionOnItem($oUser, $oPerm, $oReplaceDoc)) {
                 return "403 Forbidden - User does not have sufficient permissions";
             }
             KTDocumentUtil::delete($oReplaceDoc, 'KTWebDAV copy with overwrite set.');
             $new = false;
         }
     }
     /* ** Get the destination folder object and the source document object.
        Check if user has permission to write to the document and folder.
        Copy the document. ** */
     $oDestFolder = Folder::get($iDestFolder);
     $oSrcDoc = Document::get($iDocumentID);
     include_once KT_LIB_DIR . '/foldermanagement/folderutil.inc.php';
     $this->ktwebdavLog("Got an oSrcDoc of " . $oSrcDoc->getName() . print_r($oSrcDoc, true), 'info', true);
     $this->ktwebdavLog("Got an oDestFolder of " . $oDestFolder->getName() . print_r($oDestFolder, true), 'info', true);
     // Check if the user has permissions to write in this folder
     $oPerm =& KTPermission::getByName('ktcore.permissions.write');
     $oUser =& User::get($this->userID);
     if (!KTPermissionUtil::userHasPermissionOnItem($oUser, $oPerm, $oDestFolder)) {
         return "403 Forbidden - User does not have sufficient permissions";
     }
     $reason = isset($_SERVER['HTTP_REASON']) && !empty($_SERVER['HTTP_REASON']) ? $_SERVER['HTTP_REASON'] : "KTWebDAV Copy.";
     $oDesDoc = KTDocumentUtil::copy($oSrcDoc, $oDestFolder, $reason, $sDestFileName);
     if (PEAR::isError($oDesDoc)) {
         $this->ktwebdavLog("Copy on document failed: " . $oDesDoc->getMessage(), 'info', true);
         return "500 Internal Server Error - Copy on document failed.";
     }
     if ($new) {
         $this->ktwebdavLog("201 Created", 'info', true);
         return "201 Created";
     } else {
         $this->ktwebdavLog("204 No Content", 'info', true);
         return "204 No Content";
     }
 }
コード例 #9
0
<?php

require_once "../../config/dmsDefaults.php";
require_once KT_LIB_DIR . '/documentmanagement/documentutil.inc.php';
require_once KT_LIB_DIR . '/filelike/fsfilelike.inc.php';
$sLocalname = KT_DIR . "/tests/document/dataset1/critique-of-pure-reason.txt";
$sFilename = tempnam("/tmp", "kt_tests_document_add");
copy($sLocalname, $sFilename);
$oDocument =& Document::get(6);
if (PEAR::isError($oDocument)) {
    print "FAILURE\n";
    var_dump($oDocument);
}
$res = KTDocumentUtil::updateTransactionText($oDocument);
if (PEAR::isError($res)) {
    print "FAILURE\n";
    var_dump($res);
    exit(0);
}
コード例 #10
0
 /**
  * This adds a document to the current folder.
  *
  * <code>
  * $kt = new KTAPI();
  * $kt->start_session("admin", "admin");
  * $folder = $kt->get_folder_by_name("My New folder");
  * $res = $folder->add_document("Test Document", "test.txt", "Default", $tmpfname);
  * </code>
  *
  * @author KnowledgeTree Team
  * @access public
  * @param string $title This is the title for the file in the repository.
  * @param string $filename This is the filename in the system for the file.
  * @param string $documenttype This is the name or id of the document type. It first looks by name, then by id.
  * @param string $tempfilename This is a reference to the file that is accessible locally on the file system.
  * @return KTAPI_Document
  */
 function add_document($title, $filename, $documenttype, $tempfilename)
 {
     if (!is_file($tempfilename)) {
         return new PEAR_Error('File does not exist.');
     }
     $user = $this->can_user_access_object_requiring_permission($this->folder, KTAPI_PERMISSION_WRITE);
     if (PEAR::isError($user)) {
         return $user;
     }
     //KTS-4016: removed the replacing of special characters from the title as they should be allowed there
     //$title = KTUtil::replaceInvalidCharacters($title);
     $filename = basename($filename);
     $filename = KTUtil::replaceInvalidCharacters($filename);
     $documenttypeid = KTAPI::get_documenttypeid($documenttype);
     if (PEAR::isError($documenttypeid)) {
         $config = KTCache::getSingleton();
         $defaultToDefaultDocType = $config->get('webservice/useDefaultDocumentTypeIfInvalid', true);
         if ($defaultToDefaultDocType) {
             $documenttypeid = KTAPI::get_documenttypeid('Default');
         } else {
             return new KTAPI_DocumentTypeError('The document type could not be resolved or is disabled: ' . $documenttype);
         }
     }
     $options = array('contents' => new KTFSFileLike($tempfilename), 'temp_file' => $tempfilename, 'novalidate' => true, 'documenttype' => DocumentType::get($documenttypeid), 'description' => $title, 'metadata' => array(), 'cleanup_initial_file' => true);
     DBUtil::startTransaction();
     $document =& KTDocumentUtil::add($this->folder, $filename, $user, $options);
     if (PEAR::isError($document)) {
         DBUtil::rollback();
         return new PEAR_Error(KTAPI_ERROR_INTERNAL_ERROR . ' : ' . $document->getMessage());
     }
     DBUtil::commit();
     KTUploadManager::temporary_file_imported($tempfilename);
     return new KTAPI_Document($this->ktapi, $this, $document);
 }
コード例 #11
0
<?php

require_once "../../config/dmsDefaults.php";
require_once KT_LIB_DIR . '/documentmanagement/documentutil.inc.php';
require_once KT_LIB_DIR . '/filelike/fsfilelike.inc.php';
$sLocalname = KT_DIR . "/tests/document/dataset1/critique-of-pure-reason.txt";
$sFilename = tempnam("/tmp", "kt_tests_document_add");
copy($sLocalname, $sFilename);
$oDocument =& Document::get(207);
if (PEAR::isError($oDocument)) {
    print "FAILURE\n";
    var_dump($oDocument);
}
$res = KTDocumentUtil::storeContents($oDocument, new KTFSFileLike($sFilename));
if (PEAR::isError($res)) {
    print "FAILURE\n";
    var_dump($res);
    exit(0);
}
// storeContents can update storage_path and also status id
$oDocument->update();
if (file_exists($sFilename)) {
    unlink($sFilename);
}
コード例 #12
0
ファイル: saveMetadata.php プロジェクト: 5haman/knowledgetree
<?php

require_once "../../config/dmsDefaults.php";
require_once KT_LIB_DIR . '/documentmanagement/documentutil.inc.php';
require_once KT_LIB_DIR . '/filelike/fsfilelike.inc.php';
$oDocument =& Document::get(207);
if (PEAR::isError($oDocument)) {
    print "FAILURE\n";
    var_dump($oDocument);
}
$res = KTDocumentUtil::saveMetadata($oDocument, array());
if (PEAR::isError($res)) {
    print "FAILURE\n";
    var_dump($res);
    exit(0);
}
// saveMetadata can update status id
$oDocument->update();
if (file_exists($sFilename)) {
    unlink($sFilename);
}
コード例 #13
0
 function move($oDocument, $oToFolder, $oUser = null, $sReason = null)
 {
     //make sure we move the symlink, and the document it's linking to
     if ($oDocument->isSymbolicLink()) {
         $oDocument->switchToRealCore();
     } else {
         $oDocument->switchToLinkedCore();
     }
     $oFolder = $oToFolder;
     // alias.
     $oOriginalFolder = Folder::get($oDocument->getFolderId());
     $iOriginalFolderPermissionObjectId = $oOriginalFolder->getPermissionObjectId();
     $iDocumentPermissionObjectId = $oDocument->getPermissionObjectId();
     if ($iDocumentPermissionObjectId === $iOriginalFolderPermissionObjectId) {
         $oDocument->setPermissionObjectId($oFolder->getPermissionObjectId());
     }
     //put the document in the new folder
     $oDocument->setFolderID($oFolder->getId());
     $sName = $oDocument->getName();
     $sFilename = $oDocument->getFileName();
     $oDocument->setFileName(KTDocumentUtil::getUniqueFilename($oToFolder, $sFilename));
     $oDocument->setName(KTDocumentUtil::getUniqueDocumentName($oToFolder, $sName));
     $res = $oDocument->update();
     if (PEAR::isError($res)) {
         return $res;
     }
     //move the document on the file system(not if it's a symlink)
     if (!$oDocument->isSymbolicLink()) {
         $oStorage =& KTStorageManagerUtil::getSingleton();
         $res = $oStorage->moveDocument($oDocument, $oFolder, $oOriginalFolder);
         if (PEAR::isError($res) || $res === false) {
             $oDocument->setFolderID($oOriginalFolder->getId());
             $res = $oDocument->update();
             if (PEAR::isError($res)) {
                 return $res;
             }
             return $res;
             // we failed, bail.
         }
     }
     $sMoveMessage = sprintf(_kt("Moved from %s/%s to %s/%s. %s"), $oOriginalFolder->getFullPath(), $oOriginalFolder->getName(), $oFolder->getFullPath(), $oFolder->getName(), $sReason);
     // create the document transaction record
     $oDocumentTransaction = new DocumentTransaction($oDocument, $sMoveMessage, 'ktcore.transactions.move');
     $oDocumentTransaction->create();
     $oKTTriggerRegistry = KTTriggerRegistry::getSingleton();
     $aTriggers = $oKTTriggerRegistry->getTriggers('moveDocument', 'postValidate');
     foreach ($aTriggers as $aTrigger) {
         $sTrigger = $aTrigger[0];
         $oTrigger = new $sTrigger();
         $aInfo = array('document' => $oDocument, 'old_folder' => $oOriginalFolder, 'new_folder' => $oFolder);
         $oTrigger->setInfo($aInfo);
         $ret = $oTrigger->postValidate();
         if (PEAR::isError($ret)) {
             return $ret;
         }
     }
     // fire subscription alerts for the moved document
     $oSubscriptionEvent = new SubscriptionEvent();
     $oSubscriptionEvent->MoveDocument($oDocument, $oFolder, $oOriginalFolder);
     return KTPermissionUtil::updatePermissionLookup($oDocument);
 }
コード例 #14
0
<?php

require_once "../../config/dmsDefaults.php";
require_once KT_LIB_DIR . '/documentmanagement/documentutil.inc.php';
require_once KT_LIB_DIR . '/filelike/fsfilelike.inc.php';
$oDocument =& Document::get(22);
if (PEAR::isError($oDocument)) {
    print "FAILURE\n";
    var_dump($oDocument);
}
$res = KTDocumentUtil::validateMetadata($oDocument, array());
if (PEAR::isError($res)) {
    print "FAILURE\n";
    var_dump($res->aFailed);
    exit(0);
}
コード例 #15
0
 /**
  * This updates the metadata on the document. This includes the 'title'.
  *
  * <code>
  * $ktapi = new KTAPI();
  * $session = $ktapi->start_system_session();
  * $document = $ktapi->get_document_by_id($documentid);
  * $metadata = $document->get_metadata();
  * foreach($metadata as $key => $fieldset){
  *     if($fieldset['fieldset'] == 'XYZ'){
  *
  *         foreach($fieldset['fields'] as $k => $field){
  *             if($field['name'] == 'ABC'){
  *                 $metadata[$key][fields][$k]['value'] = 'new value';
  *             }
  *         }
  *     }
  * }
  *
  * $res = $document->update_metadata($metadata);
  * </code>
  *
  * @author KnowledgeTree Team
  * @access public
  * @param array This is an array containing the metadata to be associated with the document.
  * @return void|PEAR_Error Returns nothing on success | a PEAR_Error on failure
  */
 function update_metadata($metadata)
 {
     global $default;
     if (empty($metadata)) {
         return;
     }
     $packed = $this->get_packed_metadata($metadata);
     DBUtil::startTransaction();
     $user = $this->ktapi->get_user();
     $this->document->setLastModifiedDate(getCurrentDateTime());
     $this->document->setModifiedUserId($user->getId());
     // Update the content version / document version
     if ($default->updateContentVersion) {
         $this->document->startNewContentVersion($user);
         $this->document->setMinorVersionNumber($this->document->getMinorVersionNumber() + 1);
     } else {
         $this->document->startNewMetadataVersion($user);
     }
     $res = $this->document->update();
     if (PEAR::isError($res)) {
         DBUtil::rollback();
         return new KTAPI_Error('Unexpected failure updating document', $res);
     }
     $result = KTDocumentUtil::saveMetadata($this->document, $packed, array('novalidate' => true));
     if (is_null($result)) {
         DBUtil::rollback();
         return new PEAR_Error(KTAPI_ERROR_INTERNAL_ERROR . ': Null result returned but not expected.');
     }
     if (PEAR::isError($result)) {
         DBUtil::rollback();
         return new KTAPI_Error('Unexpected validation failure', $result);
     }
     DBUtil::commit();
     $oKTTriggerRegistry = KTTriggerRegistry::getSingleton();
     $aTriggers = $oKTTriggerRegistry->getTriggers('edit', 'postValidate');
     foreach ($aTriggers as $aTrigger) {
         $sTrigger = $aTrigger[0];
         $oTrigger = new $sTrigger();
         $aInfo = array("document" => $this->document, "aOptions" => $packed);
         $oTrigger->setInfo($aInfo);
         $ret = $oTrigger->postValidate();
     }
 }
コード例 #16
0
 function do_finalise()
 {
     $this->persistParams(array('fFileKey'));
     $sess_key = $_REQUEST['fFileKey'];
     $oForm = $this->form_metadata($sess_key);
     $res = $oForm->validate();
     if (!empty($res['errors'])) {
         return $oForm->handleError();
     }
     $data = $res['results'];
     $extra_d = $_SESSION['_add_data'][$sess_key];
     $doctypeid = $extra_d['document_type'];
     $aGenericFieldsetIds = KTFieldset::getGenericFieldsets(array('ids' => false));
     $aSpecificFieldsetIds = KTFieldset::getForDocumentType($doctypeid, array('ids' => false));
     $fieldsets = kt_array_merge($aGenericFieldsetIds, $aSpecificFieldsetIds);
     $MDPack = array();
     foreach ($fieldsets as $oFieldset) {
         $fields = $oFieldset->getFields();
         $values = (array) KTUtil::arrayGet($data, 'fieldset_' . $oFieldset->getId());
         foreach ($fields as $oField) {
             $val = KTUtil::arrayGet($values, 'metadata_' . $oField->getId());
             if ($oFieldset->getIsConditional()) {
                 if ($val == _kt('No selection.')) {
                     $val = null;
                 }
             }
             // ALT.METADATA.LAYER.DIE.DIE.DIE
             if (!is_null($val)) {
                 $MDPack[] = array($oField, $val);
             }
         }
     }
     // older code
     $mpo =& new JavascriptObserver($this);
     $oUploadChannel =& KTUploadChannel::getSingleton();
     $oUploadChannel->addObserver($mpo);
     require_once KT_LIB_DIR . '/storage/storagemanager.inc.php';
     //require_once(KT_LIB_DIR . '/filelike/fsfilelike.inc.php');
     require_once KT_LIB_DIR . '/documentmanagement/DocumentType.inc';
     require_once KT_LIB_DIR . '/metadata/fieldset.inc.php';
     require_once KT_LIB_DIR . '/documentmanagement/documentutil.inc.php';
     $aErrorOptions = array('redirect_to' => array('main', sprintf('fFolderId=%d', $this->oFolder->getId())), 'max_str_len' => 200);
     $aFile = $this->oValidator->validateFile($extra_d['file'], $aErrorOptions);
     $sTitle = $extra_d['document_name'];
     $iFolderId = $this->oFolder->getId();
     $aOptions = array('temp_file' => $aFile['tmp_name'], 'documenttype' => DocumentType::get($extra_d['document_type']), 'metadata' => $MDPack, 'description' => $sTitle, 'cleanup_initial_file' => true);
     $mpo->start();
     //$this->startTransaction();
     $oDocument =& KTDocumentUtil::add($this->oFolder, $aFile['name'], $this->oUser, $aOptions);
     if (PEAR::isError($oDocument)) {
         $message = $oDocument->getMessage();
         $this->errorRedirectTo('main', sprintf(_kt("Unexpected failure to add document - %s"), $message), 'fFolderId=' . $this->oFolder->getId());
         exit(0);
     }
     $this->addInfoMessage(_kt("Document added"));
     //$this->commitTransaction();
     $mpo->redirectToDocument($oDocument->getId());
     exit(0);
 }
コード例 #17
0
ファイル: Rename.php プロジェクト: 5haman/knowledgetree
 function do_rename()
 {
     global $default;
     $sFilename = KTUtil::arrayGet($_REQUEST, 'filename');
     $aOptions = array('redirect_to' => array('', sprintf('fDocumentId=%d', $this->oDocument->getId())), 'message' => _kt("No filename given"), 'max_str_len' => 255);
     $this->oValidator->validateString($sFilename, $aOptions);
     $this->oValidator->validateIllegalCharacters($sFilename, $aOptions);
     $res = KTDocumentUtil::rename($this->oDocument, $sFilename, $this->oUser);
     if (PEAR::isError($res)) {
         $_SESSION['KTErrorMessage'][] = $res->getMessage();
         controllerRedirect('viewDocument', sprintf('fDocumentId=%d', $this->oDocument->getId()));
     } else {
         $_SESSION['KTInfoMessage'][] = sprintf(_kt('Document "%s" renamed.'), $this->oDocument->getName());
     }
     controllerRedirect('viewDocument', sprintf('fDocumentId=%d', $this->oDocument->getId()));
     exit(0);
 }
コード例 #18
0
 /**
  * Function to fetch the actual file content of a document
  * 
  * @return $content the document file content 
  */
 function get_document_content()
 {
     // fetch the content
     $content = KTDocumentUtil::getDocumentContent($this->document);
     // TODO what if the file could not be found?
     // Log the transaction
     $this->download();
     // return the document content
     return $content;
 }
コード例 #19
0
ファイル: edit.php プロジェクト: sfsergey/knowledgetree
 function do_trytype()
 {
     $oForm = $this->form_changetype();
     $res = $oForm->validate();
     $data = $res['results'];
     $errors = $res['errors'];
     if (!empty($errors)) {
         $oForm->handleError();
     }
     $document_type = $data['type'];
     $doctypeid = $document_type->getId();
     // Get the current document type, fieldsets and metadata
     $iOldDocTypeID = $this->oDocument->getDocumentTypeID();
     $fieldsets = KTMetadataUtil::fieldsetsForDocument($this->oDocument, $iOldDocTypeID);
     $mdlist = DocumentFieldLink::getByDocument($this->oDocument);
     $field_values = array();
     foreach ($mdlist as $oFieldLink) {
         $field_values[$oFieldLink->getDocumentFieldID()] = $oFieldLink->getValue();
     }
     DBUtil::startTransaction();
     // Update the document with the new document type id
     $this->oDocument->startNewMetadataVersion($this->oUser);
     $this->oDocument->setDocumentTypeId($doctypeid);
     $res = $this->oDocument->update();
     if (PEAR::isError($res)) {
         DBUtil::rollback();
         return $res;
     }
     // Ensure all values for fieldsets common to both document types are retained
     $fs_ids = array();
     $doctype_fieldsets = KTFieldSet::getForDocumentType($doctypeid);
     foreach ($doctype_fieldsets as $fieldset) {
         $fs_ids[] = $fieldset->getId();
     }
     $MDPack = array();
     foreach ($fieldsets as $oFieldset) {
         if ($oFieldset->getIsGeneric() || in_array($oFieldset->getId(), $fs_ids)) {
             $fields = $oFieldset->getFields();
             foreach ($fields as $oField) {
                 $val = isset($field_values[$oField->getId()]) ? $field_values[$oField->getId()] : '';
                 if (!empty($val)) {
                     $MDPack[] = array($oField, $val);
                 }
             }
         }
     }
     $core_res = KTDocumentUtil::saveMetadata($this->oDocument, $MDPack, array('novalidate' => true));
     if (PEAR::isError($core_res)) {
         DBUtil::rollback();
         return $core_res;
     }
     DBUtil::commit();
     $oKTTriggerRegistry = KTTriggerRegistry::getSingleton();
     $aTriggers = $oKTTriggerRegistry->getTriggers('edit', 'postValidate');
     foreach ($aTriggers as $aTrigger) {
         $sTrigger = $aTrigger[0];
         $oTrigger = new $sTrigger();
         $aInfo = array("document" => $this->oDocument, "aOptions" => $MDPack);
         $oTrigger->setInfo($aInfo);
         $ret = $oTrigger->postValidate();
     }
     // Check if there are any dynamic conditions / permissions that need to be updated on the document
     // If there are dynamic conditions then update the permissions on the document
     // The dynamic condition test fails unless the changes exists in the DB therefore update permissions after committing the transaction.
     $iPermissionObjectId = $this->oDocument->getPermissionObjectID();
     $dynamicCondition = KTPermissionDynamicCondition::getByPermissionObjectId($iPermissionObjectId);
     if (!PEAR::isError($dynamicCondition) && !empty($dynamicCondition)) {
         $res = KTPermissionUtil::updatePermissionLookup($this->oDocument);
     }
     $this->successRedirectToMain(sprintf(_kt("You have selected a new document type: %s. "), $data['type']->getName()));
 }
コード例 #20
0
 function perform_action($oEntity)
 {
     // checkout document
     $sReason = $this->sReason;
     if (is_a($oEntity, 'Document')) {
         if ($oEntity->getImmutable()) {
             return PEAR::raiseError($oEntity->getName() . ': ' . _kt('Document cannot be checked out as it is immutable'));
         }
         if ($oEntity->getIsCheckedOut()) {
             $checkedOutUser = $oEntity->getCheckedOutUserID();
             $sUserId = $_SESSION['userID'];
             if ($checkedOutUser != $sUserId) {
                 $oCheckedOutUser = User::get($checkedOutUser);
                 return PEAR::raiseError($oEntity->getName() . ': ' . _kt('Document has already been checked out by ') . $oCheckedOutUser->getName());
             }
         } else {
             $res = KTDocumentUtil::checkout($oEntity, $sReason, $this->oUser);
             if (PEAR::isError($res)) {
                 return PEAR::raiseError($oEntity->getName() . ': ' . $res->getMessage());
             }
         }
         if ($this->bDownload) {
             if ($this->bNoisy) {
                 $oDocumentTransaction = new DocumentTransaction($oEntity, "Document part of bulk checkout", 'ktstandard.transactions.check_out', array());
                 $oDocumentTransaction->create();
             }
             $oKTTriggerRegistry = KTTriggerRegistry::getSingleton();
             $aTriggers = $oKTTriggerRegistry->getTriggers('checkoutDownload', 'postValidate');
             foreach ($aTriggers as $aTrigger) {
                 $sTrigger = $aTrigger[0];
                 $oTrigger = new $sTrigger();
                 $aInfo = array('document' => $oEntity);
                 $oTrigger->setInfo($aInfo);
                 $ret = $oTrigger->postValidate();
                 if (PEAR::isError($ret)) {
                     return $ret;
                 }
             }
             $this->oZip->addDocumentToZip($oEntity);
         }
     } else {
         if (is_a($oEntity, 'Folder')) {
             // get documents and subfolders
             $aDocuments = array();
             $oFolder = $oEntity;
             if ($oFolder->isSymbolicLink()) {
                 $oFolder = $oFolder->getLinkedFolder();
             }
             $sFolderId = $oFolder->getId();
             $sFolderDocs = $oFolder->getDocumentIDs($sFolderId);
             // get documents directly in the folder
             if (!empty($sFolderDocs)) {
                 $aDocuments = explode(',', $sFolderDocs);
             }
             // Get all the folders within the current folder
             $sWhereClause = "parent_folder_ids = '{$sFolderId}' OR\n            parent_folder_ids LIKE '{$sFolderId},%' OR\n            parent_folder_ids LIKE '%,{$sFolderId},%' OR\n            parent_folder_ids LIKE '%,{$sFolderId}'";
             $aFolderList = $this->oFolder->getList($sWhereClause);
             $aLinkingFolders = $this->getLinkingEntities($aFolderList);
             $aFolderList = array_merge($aFolderList, $aLinkingFolders);
             $aFolderObjects = array();
             $aFolderObjects[$sFolderId] = $oFolder;
             // Get the documents within the folder
             if (!empty($aFolderList)) {
                 foreach ($aFolderList as $k => $oFolderItem) {
                     if (Permission::userHasFolderReadPermission($oFolderItem)) {
                         // Get documents for each folder
                         if ($oFolderItem->isSymbolicLink()) {
                             $oFolderItem = $oFolderItem->getLinkedFolder();
                         }
                         $sFolderItemId = $oFolderItem->getID();
                         $sFolderItemDocs = $oFolderItem->getDocumentIDs($sFolderItemId);
                         if (!empty($sFolderItemDocs)) {
                             $aFolderDocs = explode(',', $sFolderItemDocs);
                             $aDocuments = array_merge($aDocuments, $aFolderDocs);
                         }
                         // Add the folder to the zip file
                         if ($this->bDownload) {
                             $this->oZip->addFolderToZip($oFolderItem);
                             $aFolderObjects[$oFolderItem->getId()] = $oFolderItem;
                         }
                     }
                 }
             }
             // Checkout each document within the folder structure
             if (!empty($aDocuments)) {
                 foreach ($aDocuments as $sDocId) {
                     $oDocument = Document::get($sDocId);
                     if (PEAR::isError($oDocument)) {
                         // add message, skip document and continue
                         $this->addErrorMessage($oDocument->getName() . ': ' . $oDocument->getMessage());
                         continue;
                     }
                     if ($oDocument->isSymbolicLink()) {
                         $oDocument->switchToLinkedCore();
                     }
                     if ($oDocument->getImmutable()) {
                         $this->addErrorMessage($oDocument->getName() . ': ' . _kt('Document cannot be checked out as it is immutable'));
                         continue;
                     }
                     // Check if the action is restricted by workflow on the document
                     if (!KTWorkflowUtil::actionEnabledForDocument($oDocument, 'ktcore.actions.document.checkout')) {
                         $this->addErrorMessage($oDocument->getName() . ': ' . _kt('Checkout is restricted by the workflow state.'));
                         continue;
                     }
                     // Check if document is already checked out, check the owner.
                     // If the current user is the owner, then include to the download, otherwise ignore.
                     if ($oDocument->getIsCheckedOut()) {
                         $checkedOutUser = $oDocument->getCheckedOutUserID();
                         $sUserId = $_SESSION['userID'];
                         if ($checkedOutUser != $sUserId) {
                             $oCheckedOutUser = User::get($checkedOutUser);
                             $this->addErrorMessage($oDocument->getName() . ': ' . _kt('Document has already been checked out by ') . $oCheckedOutUser->getName());
                             continue;
                         }
                     } else {
                         // Check out document
                         $res = KTDocumentUtil::checkout($oDocument, $sReason, $this->oUser);
                         if (PEAR::isError($res)) {
                             $this->addErrorMessage($oDocument->getName() . ': ' . _kt('Document could not be checked out. ') . $res->getMessage());
                             continue;
                         }
                     }
                     // Add document to the zip file
                     if ($this->bDownload) {
                         if ($this->bNoisy) {
                             $oDocumentTransaction = new DocumentTransaction($oDocument, 'Document part of bulk checkout', 'ktstandard.transactions.check_out', array());
                             $oDocumentTransaction->create();
                         }
                         $oKTTriggerRegistry = KTTriggerRegistry::getSingleton();
                         $aTriggers = $oKTTriggerRegistry->getTriggers('checkoutDownload', 'postValidate');
                         foreach ($aTriggers as $aTrigger) {
                             $sTrigger = $aTrigger[0];
                             $oTrigger = new $sTrigger();
                             $aInfo = array('document' => $oDocument);
                             $oTrigger->setInfo($aInfo);
                             $ret = $oTrigger->postValidate();
                             if (PEAR::isError($ret)) {
                                 return $ret;
                             }
                         }
                         $sDocFolderId = $oDocument->getFolderID();
                         $oFolder = isset($aFolderObjects[$sDocFolderId]) ? $aFolderObjects[$sDocFolderId] : Folder::get($sDocFolderId);
                         $this->oZip->addDocumentToZip($oDocument, $oFolder);
                     }
                 }
             }
         }
     }
     return true;
 }
コード例 #21
0
 function do_archive()
 {
     $oForm = $this->form_main();
     $res = $oForm->validate();
     $data = $res['results'];
     if (!empty($res['errors'])) {
         return $oForm->handleError();
     }
     $sReason = $data['reason'];
     $res = KTDocumentUtil::archive($this->oDocument, $sReason);
     if (PEAR::isError($res)) {
         $_SESSION['KTErrorMessage'][] = $res->getMessage();
         controllerRedirect('viewDocument', 'fDocumentId=' . $this->oDocument->getId());
         exit(0);
     }
     $_SESSION['KTInfoMessage'][] = _kt('Document archived.');
     controllerRedirect('browse', 'fFolderId=' . $this->oDocument->getFolderID());
     exit(0);
 }
コード例 #22
0
 /**
  * Performs a workflow transition on a document, changing it from
  * one workflow state to another, with potential side effects (user
  * scripts, and so forth).
  *
  * This function currently assumes that the user in question is
  * allowed to perform the transition and that all the guard
  * functionality on the transition has passed.
  */
 function performTransitionOnDocument($oTransition, $oDocument, $oUser, $sComments)
 {
     $oWorkflow =& KTWorkflow::getByDocument($oDocument);
     if (empty($oWorkflow)) {
         return PEAR::raiseError(_kt("Document has no workflow"));
     }
     if (PEAR::isError($oWorkflow)) {
         return $oWorkflow;
     }
     $oSourceState =& KTWorkflowUtil::getWorkflowStateForDocument($oDocument);
     // walk the action triggers.
     $aActionTriggers = KTWorkflowUtil::getActionTriggersForTransition($oTransition);
     if (PEAR::isError($aActionTriggers)) {
         return $aActionTriggers;
         // error out?
     }
     foreach ($aActionTriggers as $oTrigger) {
         $res = $oTrigger->precheckTransition($oDocument, $oUser);
         if (PEAR::isError($res)) {
             return $res;
         }
     }
     $iPreviousMetadataVersion = $oDocument->getMetadataVersionId();
     $oDocument->startNewMetadataVersion($oUser);
     KTDocumentUtil::copyMetadata($oDocument, $iPreviousMetadataVersion);
     $iStateId = $oTransition->getTargetStateId();
     $oDocument->setWorkflowStateId($iStateId);
     $res = $oDocument->update();
     if (PEAR::isError($res)) {
         return $res;
     }
     $oTargetState =& KTWorkflowState::get($iStateId);
     $sSourceState = $oSourceState->getName();
     $sTargetState = $oTargetState->getName();
     // create the document transaction record
     $sTransactionComments = sprintf(_kt("Workflow state changed from %s to %s"), $sSourceState, $sTargetState);
     if ($sComments) {
         $sTransactionComments .= _kt("; Reason given was: ") . $sComments;
     }
     $oDocumentTransaction = new DocumentTransaction($oDocument, $sTransactionComments, 'ktcore.transactions.workflow_state_transition');
     $oDocumentTransaction->create();
     // walk the action triggers.
     foreach ($aActionTriggers as $oTrigger) {
         $res = $oTrigger->performTransition($oDocument, $oUser);
         if (PEAR::isError($res)) {
             return $res;
         }
     }
     KTPermissionUtil::updatePermissionLookup($oDocument);
     KTWorkflowUtil::informUsersForState($oTargetState, KTWorkflowUtil::getInformedForState($oTargetState), $oDocument, $oUser, $sComments);
     return true;
 }
コード例 #23
0
ファイル: addInOneGo.php プロジェクト: 5haman/knowledgetree
<?php

require_once "../../config/dmsDefaults.php";
require_once KT_LIB_DIR . '/documentmanagement/documentutil.inc.php';
require_once KT_LIB_DIR . '/filelike/fsfilelike.inc.php';
error_reporting(E_ALL);
$oFolder =& Folder::get(1);
$oUser =& User::get(1);
$sLocalname = KT_DIR . "/tests/document/dataset1/critique-of-pure-reason.txt";
$sFilename = tempnam("/tmp", "kt_tests_document_add");
copy($sLocalname, $sFilename);
DBUtil::startTransaction();
$oDocument =& KTDocumentUtil::add($oFolder, "testfullupload2.txt", $oUser, array('contents' => new KTFSFileLike($sFilename), 'metadata' => array()));
if (PEAR::isError($oDocument)) {
    print "FAILURE\n";
    var_dump($oDocument);
    exit(0);
}
DBUtil::commit();
print "SUCCESS\n";
コード例 #24
0
<?php

require_once "../../config/dmsDefaults.php";
require_once KT_LIB_DIR . '/documentmanagement/documentutil.inc.php';
require_once KT_LIB_DIR . '/users/User.inc';
require_once KT_LIB_DIR . '/database/dbutil.inc';
error_reporting(E_ALL);
$oDocument = Document::get(28);
$oUser = User::get(1);
var_dump(KTDocumentUtil::rename($oDocument, 'bob1', $oUser));
var_dump(KTDocumentUtil::rename($oDocument, 'bob2', $oUser));
var_dump(KTDocumentUtil::rename($oDocument, 'bob3', $oUser));
var_dump(KTDocumentUtil::rename($oDocument, 'bob4', $oUser));