Exemple #1
0
 private function getRecordRight()
 {
     // administrátor
     $this->md_record['publisher'] = FALSE;
     $this->md_record['saver'] = FALSE;
     if (canActionAcl('mds', $this->md_record['md']['MDS'], 'w') === TRUE) {
         $this->md_record['saver'] = TRUE;
     }
     if ($this->user_admin === TRUE) {
         $this->md_record['publisher'] = TRUE;
         $this->md_record['saver'] = TRUE;
         return 'w';
     }
     // privilegia
     $privilege = 'x';
     if ($this->isPrivilege('w') === TRUE) {
         $privilege = 'w';
     } elseif ($this->isPrivilege('r') === TRUE) {
         $privilege = 'r';
     }
     setMickaLog("privilege={$privilege}", 'DEBUG', 'MdRecord.getRecordRight');
     // publikovat
     if ($this->isPrivilege('p') === TRUE) {
         $this->md_record['publisher'] = TRUE;
         setMickaLog("publisher={$privilege}", 'DEBUG', 'MdRecord.getRecordRight');
     }
     // vlastník
     if ($privilege == 'w' && $this->user == $this->md_record['md']['CREATE_USER']) {
         return 'w';
     }
     // edit_group
     if ($privilege == 'w' && $this->compareGroup($this->md_record['md']['EDIT_GROUP']) === TRUE) {
         return 'w';
     }
     // veřejný záznam
     if ($privilege == 'r' && $this->md_record['md']['DATA_TYPE'] > 0) {
         return 'r';
     }
     // view_group
     if ($privilege == 'r' && $this->compareGroup($this->md_record['md']['VIEW_GROUP']) === TRUE) {
         return 'r';
     }
     return 'x';
     // žádná práva
 }
Exemple #2
0
 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();
                 }
             }
         }
     }
 }