$uid = $_SESSION['xoopsUserId'];
    }
}
$myxoopsConfig =& xoonips_get_xoops_configs(XOOPS_CONF);
$myxoopsConfigMetaFooter =& xoonips_get_xoops_configs(XOOPS_CONF_METAFOOTER);
$doi_column_name = XNP_CONFIG_DOI_FIELD_PARAM_NAME;
$item_id = $formdata->getValue('both', 'item_id', 'i', false, 0);
$op = $formdata->getValue('both', 'op', 's', false, '');
$doi = '';
if ($doi_column_name != '') {
    $doi = $formdata->getValue('both', $doi_column_name, 's', false, '');
}
// update $item_id by the ID specified by given doi if exists $$doi_column_name param.
if ($doi != '') {
    $new_item_ids = array();
    $result = xnpGetItemIdByDoi($doi, $new_item_ids);
    // error check. $new_item_ids must be one.
    if (count($new_item_ids) == 0) {
        redirect_header(XOOPS_URL . '/', 3, _MD_XOONIPS_ITEM_DOI_NOT_FOUND);
        exit;
    } else {
        if (count($new_item_ids) > 1) {
            redirect_header(XOOPS_URL . '/', 3, _MD_XOONIPS_ITEM_DOI_DUPLICATE_ID);
            exit;
        }
    }
    $item_id = $new_item_ids[0];
    // for comment function
    $comformdata =& xoonips_getutility('formdata');
    $comformdata->set('get', 'item_id', $item_id);
    // end of comment function
 /** 
  * convert id format from "[nijc_code]:[XNP_CONFIG_DOI_FIELD_PARAM_NAME]/[sort id(doi)]" to "[nijc_code]/[item type id].[item id]"
  * @param id OAI-PMH identifier 
  * @return converted id string.
  * @return "": nijc_code not equal own nijc_code or doi above XNP_CONFIG_DOI_FIELD_PARAM_MAXLEN.   
  */
 function convertIdentifierFormat($id)
 {
     $xconfig_handler =& xoonips_getormhandler('xoonips', 'config');
     $id_str = $id;
     $parsed = $this->parseIdentifier2($id_str);
     if ($parsed) {
         if (strlen($parsed['doi']) > XNP_CONFIG_DOI_FIELD_PARAM_MAXLEN) {
             return "";
         }
         // check valid support nijc_code.
         if ($parsed['nijc_code'] != $xconfig_handler->getValue('repository_nijc_code')) {
             return "";
         }
         $iids = array();
         $item_info = "";
         $res = xnpGetItemIdByDoi($parsed['doi'], $iids);
         if ($res == RES_OK && isset($iids[0]) && xnp_get_item($_SESSION['XNPSID'], $iids[0], $item_info) == RES_OK) {
             $id_str = $parsed['nijc_code'] . "/" . $item_info['item_type_id'] . "." . $iids[0];
         } else {
             return "";
         }
     }
     return $id_str;
 }
Esempio n. 3
0
/**
 * check doi field exists in db.
 * @param doi doi.
 * @return true: doi is exists, false: doi is not exists.
 */
function xnpIsDoiExists($doi)
{
    $iids = array();
    if (xnpGetItemIdByDoi($doi, $iids) == RES_OK) {
        if (count($iids) > 0) {
            return true;
        }
    }
    return false;
}