function getMdFcDetail($recno) { $rs = array(); $md_record = new MdRecord(); $md_record->setTableMode('md'); $values = $md_record->getMdValues($recno); //my_print_r($values); //$rs['langs'] = $values['md']['LANG']; $rs['uuid'] = $values['md']['UUID']; //$rs['titles'] = $values['md']['UUID']; $rs['langs'] = ''; $rs['titles'] = ''; $rs['hodnoty'] = array(); $title_ap = ''; $title = ''; if (isset($values['md_values']) && count($values['md_values']) > 0) { foreach ($values['md_values'] as $row) { if ($row['MD_ID'] == 11) { $rs['langs'] = $rs['langs'] == '' ? $row['LANG'] : '|' . $row['LANG']; $rs['titles'] = $rs['titles'] == '' ? $row['MD_VALUE'] : '|' . $row['MD_VALUE']; $title = $row['MD_VALUE']; if ($row['LANG'] == MICKA_LANG) { $title_ap = $row['MD_VALUE']; } } if ($row['MD_ID'] == 13) { $pom['kod'] = $row['MD_VALUE']; $pom['nazev'] = $row['MD_VALUE']; array_push($rs['hodnoty'], $pom); } } } $rs['title'] = $title_ap != '' ? $title_ap : $title; //my_print_r($rs); return $rs; }
function main_rec_admin($post) { $rs = array(); $rs['akce'] = 'error'; $rs['ok'] = FALSE; $rs['report'] = ''; $rs['data'] = ''; //$recno = ($post['recno'] != '') ? htmlspecialchars($post['recno']) : -1; $recno = $_REQUEST['recno'] != '' ? htmlspecialchars($_REQUEST['recno']) : -1; if ($recno == -1) { setMickaLog('Recno=-1, not edit', 'ERROR', 'micka_main_lib.main_rec_admin'); $rs['report'] = 'Bad input! (recno -1)'; return $rs; } $form_akce = isset($post['form_akce']) ? htmlspecialchars($post['form_akce']) : 'new'; $md_record = new MdRecord(); $md_record->setTableMode('tmp'); if ($form_akce == 'new') { // editační formulář $record = $md_record->getMdValues($recno, 'xxx', 0, 0); if (isset($record['report']) && $record['report'] != 'ok') { setMickaLog("Recno={$recno}, " . $record['report'], 'ERROR', 'micka_main_lib.main_rec_admin'); $rs['report'] = $record['report']; return $rs; } $rs['ok'] = TRUE; $rs['akce'] = 'record_admin'; $rs['data']['form_akce'] = 'new'; $rs['data']['RECNO'] = $record['md']['RECNO']; //$rs['data']['DATA_TYPE'] = $record['md']['DATA_TYPE']; $rs['data']['LANG'] = $record['md']['LANG']; //$rs['data']['EDIT_GROUP'] = $record['md']['EDIT_GROUP']; //$rs['data']['VIEW_GROUP'] = $record['md']['VIEW_GROUP']; // jazyk metadat $rs['data']['md_lang'] = ''; if ($record['md']['MD_STANDARD'] == 0 || $record['md']['MD_STANDARD'] == 10) { foreach ($record['md_values'] as $row) { if ($row['MD_ID'] == 5527) { $rs['data']['md_lang'] = $row['MD_VALUE']; break; } } } } elseif ($form_akce == 'form' && count($post) > 1) { $form_data['recno'] = $recno; //$form_data['edit_group'] = $post['edit_group']; //$form_data['view_group'] = $post['view_group']; //$form_data['data_type'] = isset($post['public']) ? 1 : 0; $form_data['lang'] = isset($post['rec_lang']) && count($post['rec_lang']) > 0 ? implode('|', $post['rec_lang']) : ''; $rs['ok'] = TRUE; $rs['akce'] = 'record_admin'; $rs['data']['form_akce'] = $md_record->setRecordAdmin($form_akce, $form_data); $rs['data']['RECNO'] = $recno; //$rs['data']['DATA_TYPE'] = ''; $rs['data']['LANG'] = ''; //$rs['data']['EDIT_GROUP'] = ''; //$rs['data']['VIEW_GROUP'] = ''; } elseif ($form_akce == 'form' && count($post) < 0) { setMickaLog('Not complete input!', 'ERROR', 'micka_main_lib.main_rec_admin'); $rs['report'] = 'Not complete input!'; } elseif ($form_akce == 'warning') { $recno = isset($post['recno']) ? htmlspecialchars($post['recno']) : -1; $form_data['recno'] = $_SESSION['micka']['rec_admin']['recno']; //$form_data['edit_group'] = $_SESSION['micka']['rec_admin']['edit_group']; //$form_data['view_group'] = $_SESSION['micka']['rec_admin']['view_group']; //$form_data['data_type'] = $_SESSION['micka']['rec_admin']['data_type']; $form_data['lang'] = $_SESSION['micka']['rec_admin']['lang']; unset($_SESSION['micka']['rec_admin']); $rs['ok'] = TRUE; $rs['akce'] = 'record_admin'; $rs['data']['form_akce'] = $md_record->setRecordAdmin($form_akce, $form_data); } return $rs; }
private function setRecordsValues() { $mode_md = FALSE; if (count($this->md_head) > 0) { $md_record = new MdRecord(); $md_record->setReportValidType($this->report_valid_type['type'], $this->report_valid_type['short']); $md_record->setTableMode($this->table_mode); foreach ($this->md_head as $key => $md) { if ($this->table_mode == 'md' && canActionAcl('mds', $this->md_head[$key]['iso'], 'w') === FALSE) { $this->md_head[$key]['action'] = 'skip'; $this->md_head[$key]['right'] = 'x'; $this->setReport($key, 'error', labelTranslation(MICKA_LANG, 'guest not right')); continue; } $this->md_head[$key]['ok'] = 0; $md_record->setRecordImporting(FALSE); $this->addLogImport('setRecordsValues.MD', $md); // zaznam existuje if ($md['uuid'] != '') { if ($this->micka_lite) { $md_record->setTableMode('tmp'); } else { $md_record->setTableMode('md'); $mode_md = TRUE; } $record = $md_record->getMd('uuid', $md['uuid']); if ($mode_md === TRUE && $record['report'] == 'ok' && $record['right'] == 'w') { $this->setReport($key, 'error', "INFO: " . labelTranslation(MICKA_LANG, 'The metadata record already exists. It will be replaced with the new one when you save it.')); } if ($this->micka_lite) { $record_orig = $record; } else { $md_record->setTableMode($this->table_mode); $record_orig = $md_record->getMd('uuid', $md['uuid']); } $this->addLogImport('setRecordsValues.origMD', $record_orig); $this->addLogImport('setRecordsValues.table_mode', $this->table_mode); if ($this->table_mode == 'tmp' && canActionAcl('mds', $this->md_head[$key]['iso'], 'w') === FALSE) { if ($record_orig['report'] == 'ok' && $record_orig['report'] == 'ok') { $this->md_head[$key]['action'] = 'update'; $this->md_head[$key]['recno'] = isset($record_orig['md']['RECNO']) && $record_orig['md']['RECNO'] > 0 ? $record_orig['md']['RECNO'] : -1; } else { $this->md_head[$key]['action'] = 'insert'; } $this->md_head[$key]['right'] = 'w'; } elseif ($record['report'] == 'ok' && $record['right'] != 'w') { $this->md_head[$key]['action'] = 'skip'; $this->md_head[$key]['right'] = 'x'; $this->setReport($key, 'error', labelTranslation(MICKA_LANG, 'Record exists, import cancelled. No update rights.')); } elseif ($record['report'] == 'Not rights' && $record['right'] == 'x') { $this->md_head[$key]['action'] = 'skip'; $this->md_head[$key]['right'] = 'x'; $this->setReport($key, 'error', labelTranslation(MICKA_LANG, 'Record exists, import cancelled. No update rights.')); } elseif ($record['report'] == 'ok' && $record['right'] == 'w') { if ($this->action == 'skip') { $this->md_head[$key]['action'] = 'skip'; $this->md_head[$key]['right'] = 'w'; $this->setReport($key, 'error', labelTranslation(MICKA_LANG, 'Record exists, import cancelled.')); } else { // update if ($record_orig['report'] == 'Record not found') { // nový záznam v tmp $this->md_head[$key]['action'] = 'insert'; $this->md_head[$key]['right'] = 'w'; } else { $this->md_head[$key]['recno'] = isset($record_orig['md']['RECNO']) && $record_orig['md']['RECNO'] > 0 ? $record_orig['md']['RECNO'] : -1; $this->md_head[$key]['action'] = 'update'; $this->md_head[$key]['right'] = 'w'; //$this->md_head[$key]['report'] = ''; //$this->setReport($key, 'error', "INFO: " . labelTranslation(MICKA_LANG, 'The metadata record already exists. It will be replaced with the new one when you save it.')); $md['langs'] = $this->table_mode == 'tmp' ? getUniqueMdLangs($md['langs'], $record_orig['md']['LANG']) : $md['langs']; $this->data_type = $this->data_type == -100 ? $record_orig['md']['DATA_TYPE'] : $this->data_type; } } } elseif ($record['report'] == 'Record not found') { $this->md_head[$key]['action'] = 'insert'; $this->md_head[$key]['right'] = 'w'; } else { $this->md_head[$key]['action'] = 'skip'; $this->md_head[$key]['right'] = 'x'; $this->setReport($key, 'error', labelTranslation(MICKA_LANG, 'unknow error in MD')); } } else { // Nový záznam $this->md_head[$key]['action'] = 'insert'; $this->md_head[$key]['right'] = 'w'; } // akce $data = array(); switch ($md['iso']) { case 'MD': $data['md_standard'] = 0; break; case 'MS': case 'MC': $data['md_standard'] = 10; break; case 'DC': $data['md_standard'] = 1; break; case 'FC': $data['md_standard'] = 2; break; default: $data['md_standard'] = $this->mds; } $data['lang'] = $md['langs']; $data['server_name'] = $this->server_name; if ($this->md_head[$key]['action'] == 'insert') { // vytvoření záznamu v tabulce [md] if ($md['uuid'] != '') { $data['uuid'] = $md['uuid']; } else { $data['uuid'] = getUuid(); $this->md_head[$key]['uuid'] = $data['uuid']; } $data['edit_group'] = $this->group_e != '' ? $this->group_e : $this->user; $data['view_group'] = $this->group_v != '' ? $this->group_v : $this->user; $data['data_type'] = $this->data_type == -100 ? -1 : $this->data_type; if ($this->table_mode == 'md') { $this->md_head[$key]['recno'] = $md_record->setNewRecordMd($data, $md['lang'], $import = TRUE); } else { $this->md_head[$key]['recno'] = $md_record->setNewRecord($data, $md['lang'], $import = TRUE); } } elseif ($this->md_head[$key]['action'] == 'update' && $this->md_head[$key]['recno'] > 0) { // Aktualizace [md] if ($this->micka_lite === TRUE) { if (array_key_exists('lang', $data) === TRUE) { unset($data['lang']); } } if ($this->micka_lite === FALSE) { $data['data_type'] = $this->data_type; } $md_record->updateMdFromImport($this->md_head[$key]['recno'], $data); // Smazání [md_values] if ($this->micka_lite) { $md_record->deleteMdIdFromMdValues($this->md_head[$key]['recno'], $md['langs'], $this->del_md_id[$key]); } else { $md_record->deleteMdValuesBeforeImport($this->md_head[$key]['recno']); } } if ($this->md_head[$key]['action'] == 'insert' || $this->md_head[$key]['action'] == 'update') { // Vložení nových hodnot if ($this->md_head[$key]['recno'] > 0) { $data = array(); foreach ($this->md_values[$key] as $md_values) { $md_values['recno'] = $this->md_head[$key]['recno']; if ($this->micka_lite === TRUE && isset($record_orig['md']['LANG']) && $md_values['lang'] != 'xxx') { // pokud byl odstraněn nějaký jazyk, odstranit i data if (strpos($record_orig['md']['LANG'], $md_values['lang']) !== FALSE) { array_push($data, $md_values); } } else { array_push($data, $md_values); } } if ($this->micka_lite === FALSE) { // zachovat původní datestamp $md_record->setRecordImporting(TRUE); } $md_record->setMdValues($data); $this->md_head[$key]['ok'] = 1; $this->md_head[$key]['valid'] = $md_record->getReportValid(); } } } } }