/**
* Metainformation catalogue
* --------------------------------------------------
*
* MICKA_LIB_INSERT.PHP for MicKa
*
* @link http://www.bnhelp.cz
* @package Micka
* @category Metadata
* @version 20101120
* @authors DZ
*/
function deleteMd($user, $type, $value, $mode, $par = NULL)
{
setMickaLog('micka_lib_insert.php (deleteMd)', 'DEBUG', "user={$user}, {$type}={$value}, mode={$mode}, par={$par}");
$rs = FALSE;
// autorizace
if ($user == 'guest' || !canAction()) {
return $rs;
}
$record = getMdHeader($type, $value, $col = '', $fetch = array('all', '='));
if (isset($record[0]['RECNO']) && $record[0]['RECNO'] > -1) {
if (!getMdRight('edit', $user, $record[0]['DATA_TYPE'], $record[0]['CREATE_USER'], $record[0]['EDIT_GROUP'], $record[0]['VIEW_GROUP'])) {
return $rs;
} else {
$sql = array();
if ($mode == 'all') {
array_push($sql, 'DELETE FROM [md_values] WHERE [recno]=%i;', $record[0]['RECNO']);
array_push($sql, 'DELETE FROM [md] WHERE [recno]=%i;', $record[0]['RECNO']);
} elseif ($mode == 'value') {
array_push($sql, 'DELETE FROM [md_values] WHERE [recno]=%i AND md_id<>38;', $record[0]['RECNO']);
}
dibi::begin();
try {
dibi::query($sql);
dibi::commit();
$rs = TRUE;
} catch (DibiException $e) {
setMickaLog($e, 'ERROR', 'micka_lib_insert.php (deleteMd)');
dibi::rollback();
}
}
}
//Debug::dump($rs);
setMickaLog('micka_lib_insert.php (deleteMd)', 'DEBUG', "return={$rs}");
return $rs;
}