本文整理汇总了PHP中DBUtil::rollback方法的典型用法代码示例。如果您正苦于以下问题:PHP DBUtil::rollback方法的具体用法?PHP DBUtil::rollback怎么用?PHP DBUtil::rollback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBUtil
的用法示例。
在下文中一共展示了DBUtil::rollback方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRollback
function testRollback()
{
$f = Group::getList();
$iNumGroups = count($f);
DBUtil::startTransaction();
$g = Group::createFromArray(array('name' => 'rollback'));
if (!$this->assertGroup($g)) {
return;
}
$f = Group::getList();
$iNowNumGroups = count($f);
$this->assertEqual($iNumGroups + 1, $iNowNumGroups, 'New group not in list');
DBUtil::rollback();
$f = Group::getList();
$iRollbackNumGroups = count($f);
$this->assertEqual($iNumGroups, $iRollbackNumGroups, 'New group still in list (should be rolled back)');
}
示例2: COUNT
?>
<p>Database connectivity successful.</p>
<h3>Privileges</h3>
<?php
$selectPriv = DBUtil::runQuery('SELECT COUNT(id) FROM ' . $default->documents_table);
if (PEAR::isError($selectPriv)) {
print '<p><font color="red">Unable to do a basic database query.
Error is: ' . htmlentities($selectPriv->toString()) . '</font></p>';
} else {
print '<p>Basic database query successful.</p>';
}
$sTable = KTUtil::getTableName('system_settings');
DBUtil::startTransaction();
$res = DBUtil::autoInsert($sTable, array('name' => 'transactionTest', 'value' => 1));
DBUtil::rollback();
$res = DBUtil::getOneResultKey("SELECT id FROM {$sTable} WHERE name = 'transactionTest'", 'id');
if (!empty($res)) {
print '<p><font color="red">Transaction support not available in database</font></p>';
} else {
print '<p>Database has transaction support.</p>';
}
DBUtil::whereDelete($sTable, array('name' => 'transactionTest'));
?>
<?php
}
?>
</body>
</html>
示例3: do_trytype
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()));
}
示例4: processQueue
/**
* Loop through the queue and archive the items.
*
* @return unknown
*/
public function processQueue()
{
global $default;
// get items from queue
$queue = $this->getQueue();
if (PEAR::isError($queue)) {
$default->log->debug('Download Queue: error on fetching queue - ' . $queue->getMessage());
return false;
}
// Set queue as locked
touch($this->lockFile);
// Loop through items and create downloads
foreach ($queue as $code => $download) {
// reset the error messages
$this->errors = null;
// if the user_id is not set then skip
if (!isset($download[0]['user_id']) || empty($download[0]['user_id'])) {
$default->log->debug('Download Queue: no user id set for download code ' . $code);
$error = array(_kt('No user id has been set, the archive cannot be created.'));
$result = $this->setItemStatus($code, 3, $error);
continue;
}
// Force a session for the user
$_SESSION['userID'] = $download[0]['user_id'];
$baseFolderId = $download[0]['folder_id'];
// Create a new instance of the archival class
$zip = new ZipFolder('', $code);
$res = $zip->checkConvertEncoding();
if (PEAR::isError($res)) {
$default->log->error('Download Queue: Archive class check convert encoding error - ' . $res->getMessage());
$error = array(_kt('The archive cannot be created. An error occurred in the encoding.'));
$result = $this->setItemStatus($code, 3, $error);
continue;
}
$result = $this->setItemStatus($code, 1);
if (PEAR::isError($result)) {
$default->log->error('Download Queue: item status could not be set for user: ' . $_SESSION['userID'] . ', code: ' . $code . ', error: ' . $result->getMessage());
}
$default->log->debug('Download Queue: Creating download for user: ' . $_SESSION['userID'] . ', code: ' . $code);
DBUtil::startTransaction();
// Add the individual files and folders into the archive
foreach ($download as $item) {
if ($item['object_type'] == 'document') {
$docId = $item['object_id'];
$this->addDocument($zip, $docId);
}
if ($item['object_type'] == 'folder') {
$folderId = $item['object_id'];
$this->addFolder($zip, $folderId);
}
}
$res = $zip->createZipFile();
if (PEAR::isError($res)) {
$default->log->debug('Download Queue: Archive could not be created. Exiting transaction. ' . $res->getMessage());
DBUtil::rollback();
$error = array(_kt('The archive could not be created.'));
$result = $this->setItemStatus($code, 3, $error);
continue;
}
$default->log->debug('Download Queue: Archival successful');
$oTransaction = KTFolderTransaction::createFromArray(array('folderid' => $baseFolderId, 'comment' => "Bulk export", 'transactionNS' => 'ktstandard.transactions.bulk_export', 'userid' => $_SESSION['userID'], 'ip' => Session::getClientIP()));
if (PEAR::isError($oTransaction)) {
$default->log->debug('Download Queue: transaction could not be logged. ' . $oTransaction->getMessage());
}
DBUtil::commit();
// Set status for the download
$this->errors['archive'] = $_SESSION['zipcompression'];
$result = $this->setItemStatus($code, 2, $this->errors);
if (PEAR::isError($result)) {
$default->log->error('Download Queue: item status could not be set for user: ' . $_SESSION['userID'] . ', code: ' . $code . ', error: ' . $result->getMessage());
}
// reset the error messages
$this->errors = null;
$_SESSION['zipcompression'] = null;
}
// Remove lock file
@unlink($this->lockFile);
}
示例5: mergeWithLastMetadataVersion
/**
* Merge new metadata with previous metadata version
*
* @author KnowledgeTree Team
* @access public
* @return void|PEAR_Error Returns nothing on success | a PEAR_Error on failure
*/
function mergeWithLastMetadataVersion()
{
// keep latest metadata version
$metadata_version = $this->document->getMetadataVersion();
if ($metadata_version == 0) {
// this could theoretically happen in the case we are updating metadata and sysdata, but no metadata fields are specified.
return;
}
$metadata_id = $this->document->getMetadataVersionId();
// get previous version
$sql = "SELECT id, metadata_version FROM document_metadata_version WHERE id<{$metadata_id} AND document_id={$this->documentid} order by id desc";
$old = DBUtil::getResultArray($sql);
if (is_null($old) || PEAR::isError($old)) {
return new PEAR_Error('Previous version could not be resolved');
}
// only interested in the first one
$old = $old[0];
$old_metadata_id = $old['id'];
$old_metadata_version = $old['metadata_version'];
DBUtil::startTransaction();
// delete previous metadata version
$sql = "DELETE FROM document_metadata_version WHERE id={$old_metadata_id}";
$rs = DBUtil::runQuery($sql);
if (PEAR::isError($rs)) {
DBUtil::rollback();
return $rs;
}
// make latest equal to previous
$sql = "UPDATE document_metadata_version SET metadata_version={$old_metadata_version} WHERE id={$metadata_id}";
$rs = DBUtil::runQuery($sql);
if (PEAR::isError($rs)) {
DBUtil::rollback();
return $rs;
}
$sql = "UPDATE documents SET metadata_version={$old_metadata_version} WHERE id={$this->documentid}";
$rs = DBUtil::runQuery($sql);
if (PEAR::isError($rs)) {
DBUtil::rollback();
return $rs;
}
DBUtil::commit();
$this->clearCache();
}
示例6: archive
/**
* Bulk archives a list of folders and/or documents
*
* <code>
* $ktapi = new KTAPI();
* $session = $ktapi->start_system_session();
* $document = $ktapi->get_document_by_id($documentid);
* $folder = $ktapi->get_folder_by_name('New test folder');
*
* $aItems = array($document, $folder);
* $bulk = new KTAPI_BulkActions($ktapi)
* $res = $bulk->archive($aItems, 'Bulk archive');
*
* // if documents / folders failed
* if(!empty($res)) {
* // display reason for documents failure
* foreach($res['docs'] as $failedDoc){
* echo '<br>' . $failedDoc['object']->get_title() . ' - reason: '.$failedDoc['reason'];
* }
* // display reason for folders failure
* foreach($res['folders'] as $failedDoc){
* echo '<br>' . $failedFolder['object']->get_folder_name() . ' - reason: '.$failedFolder['reason'];
* }
* }
* </code>
*
* @author KnowledgeTree Team
* @access public
* @param array $items The folders and/or documents
* @param string $reason The reason for performing the archival
* @return void|PEAR_Error Nothing on success | PEAR_Error on failure
*/
function archive($items, $reason)
{
if (empty($items)) {
return;
}
if (!is_array($items)) {
$items = array($items);
}
// Archive the document or folder
// Items that fail are returned in an array with the reason for failure.
$failed = array();
foreach ($items as $item) {
// Documents
if ($item instanceof KTAPI_Document) {
$res = $item->archive($reason);
if (PEAR::isError($res)) {
$failed['docs'][] = array('object' => $item, 'reason' => $res->getMessage());
continue;
}
} else {
if ($item instanceof KTAPI_Folder) {
// Folders - need to recurse in
DBUtil::startTransaction();
$res = $this->recurseFolder($item, $reason, 'archive');
if (PEAR::isError($res)) {
DBUtil::rollback();
$failed['folders'][] = array('object' => $item, 'reason' => $res->getMessage());
continue;
}
DBUtil::commit();
}
}
}
return $failed;
}
示例7: copy
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..
//.........这里部分代码省略.........
示例8: rollbackTransaction
function rollbackTransaction()
{
DBUtil::rollback();
$this->bTransactionStarted = false;
}
示例9: temporary_file_imported
function temporary_file_imported($tempfilename)
{
$tempfilename = addslashes(str_replace('\\', '/', $tempfilename));
$sql = "DELETE FROM uploaded_files WHERE tempfilename='{$tempfilename}'";
$rs = DBUtil::runQuery($sql);
if (PEAR::isError($rs)) {
DBUtil::rollback();
return false;
}
return true;
}
示例10: copy
/**
* This copies a folder to another location.
*
* <code>
* $root = $this->ktapi->get_root_folder();
* $folder = $root->add_folder("Test folder");
* $new_folder = $root->add_folder("New test folder");
* $res = $folder->copy($new_folder, "Test copy");
* </code>
*
* @author KnowledgeTree Team
* @access public
* @param KTAPI_Folder $ktapi_target_folder
* @param string $reason
*/
function copy($ktapi_target_folder, $reason = '')
{
assert(!is_null($ktapi_target_folder));
assert(is_a($ktapi_target_folder, 'KTAPI_Folder'));
$user = $this->ktapi->get_user();
$target_folder = $ktapi_target_folder->get_folder();
$result = $this->can_user_access_object_requiring_permission($target_folder, KTAPI_PERMISSION_WRITE);
if (PEAR::isError($result)) {
return $result;
}
DBUtil::startTransaction();
$result = KTFolderUtil::copy($this->folder, $target_folder, $user, $reason);
if (PEAR::isError($result)) {
DBUtil::rollback();
return new KTAPI_Error(KTAPI_ERROR_INTERNAL_ERROR, $result);
}
DBUtil::commit();
}
示例11: deleteVersion
/**
* Delete a selected version of the document.
*/
function deleteVersion($oDocument, $iVersionID, $sReason)
{
$oDocument =& KTUtil::getObject('Document', $oDocument);
$oVersion =& KTDocumentMetadataVersion::get($iVersionID);
$oStorageManager =& KTStorageManagerUtil::getSingleton();
global $default;
if (empty($sReason)) {
return PEAR::raiseError(_kt('Deletion requires a reason'));
}
if (PEAR::isError($oDocument) || $oDocument == false) {
return PEAR::raiseError(_kt('Invalid document object.'));
}
if (PEAR::isError($oVersion) || $oVersion == false) {
return PEAR::raiseError(_kt('Invalid document version object.'));
}
$iContentId = $oVersion->getContentVersionId();
$oContentVersion = KTDocumentContentVersion::get($iContentId);
if (PEAR::isError($oContentVersion) || $oContentVersion == false) {
return PEAR::raiseError(_kt('Invalid document content version object.'));
}
// Check that the document content is not the same as the current content version
$sDocStoragePath = $oDocument->getStoragePath();
$sVersionStoragePath = $oContentVersion->getStoragePath();
if ($sDocStoragePath == $sVersionStoragePath) {
return PEAR::raiseError(_kt("Can't delete version: content is the same as the current document content."));
}
DBUtil::startTransaction();
// now delete the document version
$res = $oStorageManager->deleteVersion($oVersion);
if (PEAR::isError($res) || $res == false) {
//could not delete the document version from the file system
$default->log->error('Deletion: Filesystem error deleting the metadata version ' . $oVersion->getMetadataVersion() . ' of the document ' . $oDocument->getFileName() . ' from folder ' . Folder::getFolderPath($oDocument->getFolderID()) . ' id=' . $oDocument->getFolderID());
// we use a _real_ transaction here ...
DBUtil::rollback();
return PEAR::raiseError(_kt('There was a problem deleting the document from storage.'));
}
// change status for the metadata version
$oVersion->setStatusId(VERSION_DELETED);
$oVersion->update();
// set the storage path to empty
// $oContentVersion->setStoragePath('');
DBUtil::commit();
}
示例12: do_import
function do_import()
{
set_time_limit(0);
$aErrorOptions = array('redirect_to' => array('main', sprintf('fFolderId=%d', $this->oFolder->getId())));
$aErrorOptions['message'] = _kt('Invalid document type provided');
$oDocumentType = $this->oValidator->validateDocumentType($_REQUEST['fDocumentTypeId'], $aErrorOptions);
$aErrorOptions['message'] = _kt('Invalid path provided');
$sPath = $this->oValidator->validateString($_REQUEST['path'], $aErrorOptions);
$matches = array();
$aFields = array();
foreach ($_REQUEST as $k => $v) {
if (preg_match('/^metadata_(\\d+)$/', $k, $matches)) {
$aFields[] = array(DocumentField::get($matches[1]), $v);
}
}
$aOptions = array('documenttype' => $oDocumentType, 'metadata' => $aFields, 'copy_upload' => 'true');
$po =& new JavascriptObserver($this);
$po->start();
$oUploadChannel =& KTUploadChannel::getSingleton();
$oUploadChannel->addObserver($po);
$fs =& new KTFSImportStorage($sPath);
$bm =& new KTBulkImportManager($this->oFolder, $fs, $this->oUser, $aOptions);
DBUtil::startTransaction();
$res = $bm->import();
if (PEAR::isError($res)) {
DBUtil::rollback();
$_SESSION["KTErrorMessage"][] = _kt("Bulk import failed") . ": " . $res->getMessage();
} else {
DBUtil::commit();
$this->addInfoMessage(_kt("Bulk import succeeded"));
}
$po->redirectToFolder($this->oFolder->getId());
exit(0);
}
示例13: do_import
//.........这里部分代码省略.........
$oDocumentType = $this->oValidator->validateDocumentType($requestDocumentType, $aErrorOptions);
$aErrorOptions['message'] = _kt('Invalid path provided');
$tmpPath = $_REQUEST['path'];
//Backwards compatibility
if ($tmpPath == '') {
$tmpPath = $_REQUEST['data'];
$tmpPath = $tmpPath['path'];
}
$sPath = $this->oValidator->validateString($tmpPath, $aErrorOptions);
/*
$matches = array();
$aFields = array();
foreach ($_REQUEST as $k => $v) {
if (preg_match('/^metadata_(\d+)$/', $k, $matches)) {
// multiselect change start
$oDocField = DocumentField::get($matches[1]);
if(KTPluginUtil::pluginIsActive('inet.multiselect.lookupvalue.plugin') && $oDocField->getHasInetLookup() && is_array($v))
{
$v = join(", ", $v);
}
$aFields[] = array($oDocField, $v);
// previously it was just one line which is commented, just above line
// multiselect change end
}
}
$aOptions = array(
'documenttype' => $oDocumentType,
'metadata' => $aFields,
'copy_upload' => 'true',
);
*/
// Newer metadata form field catcher that works with ktcore form array type fields named like
// name='metadata[fieldset][metadata_9]'
$aData = $_REQUEST['data'];
$data = $aData;
/*
$oForm = $this->getBulkImportForm();
$res = $oForm->validate();
if (!empty($res['errors'])) {
return $oForm->handleError();
}
$data = $res['results'];
*/
$doctypeid = $requestDocumentType;
$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());
//Fix for multiselect not submitting data due to the value not being flat.
$sVal = '';
if (is_array($val)) {
foreach ($val as $v) {
$sVal .= $v . ", ";
}
$sVal = substr($sVal, 0, strlen($sVal) - 2);
$val = $sVal;
}
if ($oFieldset->getIsConditional()) {
if ($val == _kt('No selection.')) {
$val = null;
}
}
if (!is_null($val)) {
$MDPack[] = array($oField, $val);
}
}
}
$aOptions = array('documenttype' => $oDocumentType, 'metadata' => $MDPack, 'copy_upload' => 'true');
$po =& new JavascriptObserver($this);
$po->start();
$oUploadChannel =& KTUploadChannel::getSingleton();
$oUploadChannel->addObserver($po);
$fs =& new KTFSImportStorage($sPath);
$bm =& new KTBulkImportManager($this->oFolder, $fs, $this->oUser, $aOptions);
if (KTPluginUtil::pluginIsActive('inet.foldermetadata.plugin')) {
require_once KT_DIR . "/plugins/foldermetadata/import/bulkimport.inc.php";
$bm =& new KTINETBulkImportManager($this->oFolder, $fs, $this->oUser, $aOptions);
} else {
$bm =& new KTBulkImportManager($this->oFolder, $fs, $this->oUser, $aOptions);
}
DBUtil::startTransaction();
$res = $bm->import();
if (PEAR::isError($res)) {
DBUtil::rollback();
$_SESSION["KTErrorMessage"][] = _kt("Bulk import failed") . ": " . $res->getMessage();
} else {
DBUtil::commit();
$this->addInfoMessage(_kt("Bulk import succeeded"));
}
$po->redirectToFolder($this->oFolder->getId());
exit(0);
}