Skip to content

Commit

Permalink
Merge pull request #250 from kitodo/fix-81
Browse files Browse the repository at this point in the history
Fix #81
  • Loading branch information
sebastian-meyer authored Dec 20, 2017
2 parents f2c5014 + a1bd1d0 commit b811c39
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions dlf/common/class.tx_dlf_document.php
Original file line number Diff line number Diff line change
Expand Up @@ -1404,18 +1404,20 @@ public function save($pid = 0, $core = 0) {
$metadata['collection'] = $collections;

// Get UID for owner.
$owner = !empty($metadata['owner'][0]) ? $metadata['owner'][0] : 'default';

$result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'tx_dlf_libraries.uid AS uid',
'tx_dlf_libraries',
'tx_dlf_libraries.pid='.intval($pid).' AND tx_dlf_libraries.index_name='.$GLOBALS['TYPO3_DB']->fullQuoteStr($metadata['owner'][0], 'tx_dlf_libraries').tx_dlf_helper::whereClause('tx_dlf_libraries'),
'tx_dlf_libraries.pid='.intval($pid).' AND tx_dlf_libraries.index_name='.$GLOBALS['TYPO3_DB']->fullQuoteStr($owner, 'tx_dlf_libraries').tx_dlf_helper::whereClause('tx_dlf_libraries'),
'',
'',
'1'
);

if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) {

list ($owner) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result);
list ($ownerUid) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result);

} else {

Expand All @@ -1424,8 +1426,8 @@ public function save($pid = 0, $core = 0) {

$libData['tx_dlf_libraries'][$libNewUid] = array (
'pid' => $pid,
'label' => $metadata['owner'][0],
'index_name' => $metadata['owner'][0],
'label' => $owner,
'index_name' => $owner,
'website' => '',
'contact' => '',
'image' => '',
Expand All @@ -1440,13 +1442,13 @@ public function save($pid = 0, $core = 0) {
$substUid = tx_dlf_helper::processDB($libData);

// Add new library's UID.
$owner = $substUid[$libNewUid];
$ownerUid = $substUid[$libNewUid];

if (!defined('TYPO3_cliMode')) {

$message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
'TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
htmlspecialchars(sprintf(tx_dlf_helper::getLL('flash.newLibrary'), $metadata['owner'][0], $owner)),
htmlspecialchars(sprintf(tx_dlf_helper::getLL('flash.newLibrary'), $owner, $ownerUid)),
tx_dlf_helper::getLL('flash.attention', TRUE),
\TYPO3\CMS\Core\Messaging\FlashMessage::INFO,
TRUE
Expand All @@ -1458,7 +1460,7 @@ public function save($pid = 0, $core = 0) {

}

$metadata['owner'][0] = $owner;
$metadata['owner'][0] = $ownerUid;

// Get UID of parent document.
$partof = 0;
Expand Down

0 comments on commit b811c39

Please sign in to comment.