Exemple #1
0
/**
 * 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;
}
Exemple #2
0
 /**
  * Je uživatel administrátor?
  * @param string $right
  */
 private function setUserAdmin()
 {
     if (canAction('*') === FALSE) {
         $this->user_admin = FALSE;
     } else {
         $this->user_admin = TRUE;
     }
 }
Exemple #3
0
/**
 * Metainformation catalogue
 * --------------------------------------------------
 *
 * HARVEST for MicKa
 *
 * @link       http://www.bnhelp.cz
 * @package    Micka admin
 * @category   Metadata
 * @version    20140522
 */
function adminHarvest($harvestAction)
{
    $params = array();
    while (list($key, $val) = each($_REQUEST)) {
        $params[$key] = htmlspecialchars($val);
    }
    $harvest = new Harvest(null, null);
    $rs = array();
    $rs['types'] = array_flip($harvest->types);
    $rs['error'] = '';
    //my_print_r($params); my_print_r($harvestAction); //exit;
    switch ($harvestAction) {
        case 'save':
            $overwrite = isset($params['new']) && $params['new'] == 1 ? false : true;
            if ($params['handlers']) {
                $handlers = "email:" . $params['handlers'];
            }
            if ($params['period'] <= 0) {
                $params['period'] = "0";
            }
            if ($params['ok']) {
                if (!canAction('*')) {
                    $params['active'] = 0;
                }
                $result = $harvest->setParameters($params['id'], $params['source'], $params['type'], $handlers, "P" . $params['period'] . "D", $params['filter'], $params['active'], $overwrite);
                if ($result['status'] == 'fail') {
                    $rs['error'] = $result['error'];
                }
            }
            break;
        case 'edit':
            if ($params['id'] && $result['status'] != 'fail') {
                $par = $harvest->getParameters($params['id']);
                $params = $par[0];
                $days = $par[0]['h_interval'] / 24;
                $params['period'] = $days;
                $email = explode(":", $params['handlers']);
                $params['handlers'] = $email[1];
            } else {
                $rs['new'] = '1';
            }
            $rs['values'] = $params;
            $rs['isadmin'] = canAction('*');
            return $rs;
        case 'delete':
            $harvest->delete($params['id']);
            break;
        default:
            break;
    }
    $rs['list'] = $harvest->getParameters();
    //my_print_r($rs); exit;
    return $rs;
}
Exemple #4
0
/**
 * Metainformation catalogue
 * --------------------------------------------------
 *
 * AuthLib for MicKa
 *
 * @link       http://www.bnhelp.cz
 * @package    Micka
 * @category   Metadata
 * @version    20121026
 */
function canActionAcl($type, $resource, $privilege)
{
    $rs = FALSE;
    if (isset($_SESSION['micka']['acl']) === TRUE) {
        if (array_key_exists($resource, $_SESSION['micka']['acl'][$type])) {
            if (strpos($_SESSION['micka']['acl'][$type][$resource], $privilege) !== FALSE) {
                $rs = TRUE;
            }
        }
    } else {
        // starý způsob
        $rs = canAction($privilege);
    }
    return $rs;
}
Exemple #5
0
 /**
  * Performs Trasaction (save/update data in underlying database)
  *
  */
 function transaction()
 {
     if (!canAction('w')) {
         $this->exception(1, "Transaction", "You don't have permission to transaction.");
     }
     $this->logText .= strtoupper($this->params['REQTYPE']);
     switch (strtolower($this->params['REQTYPE'])) {
         case "csw:delete":
             return $this->updateResponse($this->delete(), "Delete");
             break;
         case "csw:update":
             return $this->updateResponse($this->update('', $this->params['GROUP_EDIT'], $this->params['GROUP_READ'], $this->params['IS_PUBLIC'], false, 'update'), "Update");
             break;
         case "csw:insert":
             return $this->updateResponse($this->update('', $this->params['GROUP_EDIT'], $this->params['GROUP_READ'], $this->params['IS_PUBLIC'], false, 'insert'), "Insert");
             break;
         default:
             $this->exception(3, $this->params['REQTYPE'], "Not supported transaction type.");
             break;
     }
     return false;
 }
Exemple #6
0
 private function setUserAdmin()
 {
     $this->user_admin = canAction('*');
 }
Exemple #7
0
function mainAdmin($admin_ak)
{
    if (canAction('*') === FALSE) {
        require PHPINC_DIR . '/templates/403.php';
    }
    $rs = array();
    $rs['template'] = 'default';
    $rs['label'] = 'default';
    if ($admin_ak == 'default') {
        /*
        		//$rs['data'][] = array('action' => 'md_contacts', 'label' => 'Správa kontaktů');
        		$rs['data'][] = array('action' => 'hsusers', 'label' => 'Správa uživatelů');
        		$rs['data'][] = array('action' => 'profils', 'label' => 'Správa profilů');
        		$rs['data'][] = array('action' => 'mdreplace', 'label' => 'Hromadná editace');
        		$rs['data'][] = array('action' => 'harvest', 'label' => 'Harvest');
        */
        $rs['data'][] = array('action' => 'hsusers', 'label' => 'Identity management');
        $rs['data'][] = array('action' => 'profils', 'label' => 'Managing profiles');
        $rs['data'][] = array('action' => 'mdreplace', 'label' => 'Bulk edits');
        $rs['data'][] = array('action' => 'harvest', 'label' => 'Harvest');
        $rs['data'][] = array('action' => 'mdsummary', 'label' => 'Summary metadata records');
    } else {
        require PHPINC_DIR . '/admin/' . $admin_ak . '/index.php';
        $rs['template'] = $adminDataBox['template'];
        $rs['data'] = $adminDataBox['data'];
        $rs['label'] = $adminDataBox['label'];
    }
    //Debugger::dump($rs);
    return $rs;
}
Exemple #8
0
function getMdRight($type, $user, $data_type, $create_user, $edit_group, $view_group)
{
    setMickaLog("type={$type}, user={$user}, data_type={$data_type}, create={$create_user}, edit={$edit_group}, view={$view_group}", 'ERROR', 'getMdRight.start');
    $rs = FALSE;
    if (canAction('*')) {
        // root - superuživatel, správce projektu, může vše
        setMickaLog('TRUE', 'ERROR', 'getMdRight.root');
        return TRUE;
    } else {
        setMickaLog('FALSE', 'ERROR', 'getMdRight.root');
    }
    if ($type == 'edit' && $user != 'guest') {
        if (getMsGroups('is_set', $edit_group) || $user == $create_user) {
            return TRUE;
        }
    }
    if ($type == 'view') {
        if ($user == $create_user) {
            return TRUE;
        } elseif (getMsGroups('is_set', $edit_group)) {
            return TRUE;
        } elseif (getMsGroups('is_set', $view_group) && $data_type > -1) {
            return TRUE;
        } elseif ($data_type > 0) {
            return TRUE;
        }
    }
    return $rs;
}
Exemple #9
0
require PHPPRG_DIR . '/micka_lib.php';
require PHPPRG_DIR . '/micka_auth.php';
$substring = DB_DRIVER == 'oracle' ? 'SUBSTR' : 'SUBSTRING';
$sql = array();
$org = array();
$md_id = array();
$rs = array();
$recno = '';
$orderBy = TRUE;
$query_lang = isset($_REQUEST['lang']) && $_REQUEST['lang'] != '' ? htmlspecialchars($_REQUEST['lang']) : '';
$creator = isset($_REQUEST['creator']) && $_REQUEST['creator'] != '' ? htmlspecialchars($_REQUEST['creator']) : '';
$query = isset($_REQUEST['query']) && $_REQUEST['query'] != '' ? htmlspecialchars($_REQUEST['query']) : '';
$contact_type = isset($_REQUEST['type']) && $_REQUEST['type'] != '' ? htmlspecialchars($_REQUEST['type']) : 'org';
$contact_role = isset($_REQUEST['role']) && $_REQUEST['role'] != '' ? htmlspecialchars($_REQUEST['role']) : '';
$user = MICKA_USER;
$admin = canAction('*');
$group = getMsGroups('get_groups');
$group = implode("','", array_keys($group));
$group = "'" . $group . "'";
if ($admin === TRUE) {
    $right = 'md.data_type IS NOT NULL';
} else {
    $right = $user == 'guest' ? 'md.data_type>0' : "(md.create_user='******' OR md.view_group IN({$group}) OR md.edit_group IN({$group}) OR md.data_type>0)";
}
switch ($contact_type) {
    case 'mdperson':
        //$md_id = array(152);
        $query_lang = '';
        array_push($sql, "\n            SELECT md_values.recno, md_values.md_path, md_values.md_value, md_values.lang\n            FROM (md JOIN md_values ON md.recno=md_values.recno) LEFT JOIN md_values m ON({$substring}(md_values.md_path, 1,17)={$substring}(m.md_path, 1,17) AND md_values.recno=m.recno)\n            WHERE \n        ");
        if ($creator != '') {
            if ($creator == $user) {
Exemple #10
0
 public function getXML($in, $params, $result = TRUE, $only_xml = FALSE)
 {
     //Debugger::dump($in);exit;
     //Debugger::log('[MdExport.getXML.begin] ' . print_r($in, true), 'INFO');
     $this->rs_xml = '';
     $rs_type = $only_xml === TRUE ? 'xml' : 'array';
     $rs_md = array();
     $supr = canAction('*');
     // root - superuživatel, spravce projektu
     $vysl = array();
     $recno_arr = array();
     if (is_array($in) === FALSE) {
         $in = array();
     }
     if (is_array($params) === FALSE) {
         $params = array();
     }
     $this->setFlatParams($params);
     $this->setQueryIn($in);
     $in = $this->query_in;
     $pom = $this->setQuery($this->setMdParams($in));
     if ($pom == -1) {
         setMickaLog('SQL == -1', 'ERROR', 'MdExport.getXML');
         // TODO: návrat chyby
         /*
         if ($this->query_status === FALSE) {
         	my_print_r($this->query_error);
         }
         */
         return -1;
     }
     if ($this->search_uuid === FALSE) {
         $numberOfRecods = $this->setNumberOfRecords($this->startPosition + 1, $pom['paginator']['records']);
     }
     if ($pom['paginator']['records'] > 0 && $pom['sql'] != '' && $this->hits === FALSE) {
         if ($this->xml_from == 'cache') {
             $vysl = _executeSql('select', array($pom['sql']), array('all'));
             //Debugger::log('[MdExport.getXML.vysl] ' . print_r($vysl, true), 'ERROR');
             $recno_arr = array_keys($vysl);
             if ($this->search_uuid === TRUE) {
                 if (is_array($vysl) === FALSE && $vysl == '') {
                     $vysl = array();
                 }
                 $numberOfRecods = $this->setNumberOfRecords($this->startPosition + 1, count($vysl));
             }
         } else {
             $elements_label = $this->getIdElements();
             // nacteni elementu pro prevod na kody
             $result_db = DB_DRIVER == 'oracle' ? _executeSql('select', array($pom['sql']), array('assoc', 'RECNO,#,=')) : _executeSql('select', array($pom['sql']), array('assoc', 'recno,#,='));
             $eval_text = '';
             foreach ($result_db as $recno => $data) {
                 $recno_arr[] = $recno;
                 // seznam recno
                 foreach ($data as $idx => $row) {
                     if ($row['MD_PATH'] == '') {
                         continue;
                     }
                     $mds = $row['MD_STANDARD'];
                     if ($mds - 10 > -1) {
                         $mds = $mds - 10;
                     }
                     $path_arr = explode('_', substr($row['MD_PATH'], 0, strlen($row['MD_PATH']) - 1));
                     $eval_text_tmp = '$vysl[' . $recno . ']';
                     foreach ($path_arr as $key => $value) {
                         if ($key % 2 == 0) {
                             $eval_text_tmp .= "['" . $elements_label[$mds][$value] . "']";
                         } else {
                             $eval_text_tmp .= '[' . $value . ']';
                         }
                     }
                     $eval_text_tmp .= "['!" . $row['LANG'] . "']=" . '"' . gpc_addslashes($row['MD_VALUE']) . '";' . "\n";
                     $eval_text .= $eval_text_tmp;
                 }
             }
             eval($eval_text);
         }
         $this->md = array();
         if (count($recno_arr) == 0) {
             // TODO: otestovat stav, kdy požaduji záznam vyšší, než je počet nalezených
             //$numberOfRecods['Return'] = 0;
         } elseif ($this->xml_from == 'data') {
             $this->setMdHeader($recno_arr);
         }
     }
     if ($result) {
         $this->rs_xml .= "<results numberOfRecordsMatched=\"" . $numberOfRecods['Matched'] . "\" numberOfRecordsReturned=\"" . $numberOfRecods['Return'] . "\" nextRecord=\"" . $numberOfRecods['Next'] . "\" elementSet=\"brief\">";
     }
     if (is_array($vysl) && $this->hits === FALSE) {
         if ($this->xml_from == 'data') {
             $this->printMDXML($vysl);
         }
         if ($this->xml_from == 'cache') {
             foreach ($vysl as $key => $item) {
                 if (DB_DRIVER == 'mssql2005' && is_object($item['LAST_UPDATE_DATE'])) {
                     $item['CREATE_DATE'] = $item['CREATE_DATE']->format('Y-m-d');
                     $item['LAST_UPDATE_DATE'] = $item['LAST_UPDATE_DATE']->format('Y-m-d');
                 }
                 $item['edit'] = 0;
                 if (getMsGroups('is_set', $item['EDIT_GROUP']) || $supr) {
                     $item['edit'] = 1;
                 }
                 if ($item['CREATE_USER'] == $this->user && $this->user != 'guest') {
                     $item['edit'] = 1;
                 }
                 if ($this->ext_header === TRUE) {
                     $item = $item + $this->getHarvestor($item['SERVER_NAME']);
                 } else {
                     $item['harvest_source'] = '';
                     $item['harvest_title'] = '';
                 }
                 if ($rs_type == 'xml') {
                     $this->rs_xml .= '<rec recno="' . $item['RECNO'] . '"' . ' uuid="' . $item['UUID'] . '"' . ' md_standard="' . $item['MD_STANDARD'] . '"' . ' lang="' . $item['LANG'] . '"' . ' data_type="' . $item['DATA_TYPE'] . '"' . ' create_user="******"' . ' create_date="' . $item['CREATE_DATE'] . '"' . ' last_update_user="******"' . ' last_update_date="' . $item['LAST_UPDATE_DATE'] . '"' . ' edit_group="' . $item['EDIT_GROUP'] . '"' . ' view_group="' . $item['VIEW_GROUP'] . '"' . ' valid="' . $item['VALID'] . '"' . ' prim="' . $item['PRIM'] . '"' . ' server_name="' . $item['SERVER_NAME'] . '"' . ' harvest_source="' . $item['harvest_source'] . '"' . ' harvest_title="' . $item['harvest_title'] . '"' . ' edit="' . $item['edit'] . '">' . $item['PXML'] . "</rec>";
                 } else {
                     $this->rs_xml .= $item['PXML'];
                     unset($item['PXML']);
                     $rs_md[] = $item;
                 }
             }
         }
     }
     if ($result) {
         $this->rs_xml .= "\n";
         $this->rs_xml .= "</results>";
     }
     //$this->set2FileLog(array($in, $pom['sql'], $this->rs_xml, $rs_md));
     $_SESSION['micka']['search']['xmlMatched'] = $numberOfRecods['Matched'];
     if ($rs_type == 'xml') {
         return $this->rs_xml;
     }
     return array($this->rs_xml, $rs_md);
 }
Exemple #11
0
$template->registerHelperLoader('TemplateHelpers::loader');
$template->registerFilter(new LatteFilter());
$template->setFile(PHPINC_DIR . '/templates/micka.latte');
parse_str($_SERVER['QUERY_STRING'], $url_params);
$template->urlParams = $url_params;
$template->basePath = substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], '/'));
$template->themePath = $template->basePath . '/themes/' . MICKA_THEME;
$template->extjsPath = EXTJS_PATH;
$template->openLayersPath = OPENLAYERS_PATH;
$template->label = getLabelAllAP();
$template->action = $ak;
$template->MICKA_LANG = MICKA_LANG;
$template->MICKA_USER = MICKA_USER;
$template->FORM_SIGN = FORM_SIGN;
$template->admin = canAction('*') ? 1 : 0;
$template->insertRight = canAction('w') ? 1 : 0;
$template->flashes = getFlashMessage();
//$template->flashes = array(0 => array('type' => 'error', 'message' => 'Chybka'));
$template->navigation = $ak == 'edit' || $ak == 'detail' || $ak == 'valid' || $ak == 'admin' || $ak == 'detailall' ? mainNavigation($ak, $template->label, $record['data']['md']['UUID']) : mainNavigation($ak, $template->label);
//Debugger::dump($template->navigation); exit;
//$template->usrBox = 'volitelný';
//$template->sortBox = 'sort';
//$template->labelBox = 'label';
$template->dataBox = isset($dataBox) ? $dataBox : '';
$template->mickaLangsArr = $micka_langs_arr;
//$template->footBox = 'patička';
if ($ak == 'about') {
    $template->about = array('verApp' => MICKA_VERSION, 'verDb' => getDbVersion());
} elseif ($ak == 'search') {
    $template->hs_initext = $hs_initext;
    /*
Exemple #12
0
 function getParameters($name = null)
 {
     $sql = array();
     $sql[] = 'SELECT * FROM harvest';
     if ($name) {
         array_push($sql, 'WHERE name=%s', $name);
     }
     if (!canAction('*')) {
         if ($name) {
             array_push($sql, 'AND create_user=%s', MICKA_USER);
         } else {
             array_push($sql, 'WHERE create_user=%s', MICKA_USER);
         }
     }
     array_push($sql, 'ORDER BY name');
     try {
         $rs = dibi::query($sql);
         $rs = _executeSql('select', $sql, array('all'));
         //$result =  $rs->fetchAll();
         foreach ($rs as $row) {
             $result[] = array("id" => $row['NAME'], "source" => $row['SOURCE'], "type" => $row['TYPE'], "h_interval" => $row['H_INTERVAL'], "HarvestInterval" => $row['PERIOD'], "handlers" => $row['HANDLERS'], "filter" => $row['FILTER'], "active" => $row['ACTIVE'], "updated" => $row['UPDATED']);
         }
     } catch (DibiException $e) {
         var_dump($e);
         $result = false;
     }
     return $result;
 }