/** * * export 'Related to' information of an item. * * @param parent_id id of the item to export. * @return generated XML or NULL */ function xnpExportRelatedTo($parent_id) { $xnpsid = $_SESSION['XNPSID']; $xml = array(); $item_id = array(); // Export item: only accesible item // ->export link information getted xnp_get_related_to. $res = xnp_get_related_to($xnpsid, $parent_id, $item_id); if ($res != RES_OK) { return NULL; } $xml = ''; foreach ($item_id as $i) { $xml = $xml . "<related_to item_id='{$i}'/>\n"; } return $xml; }
function xnpGetModifiedFields($item_id) { $xnpsid = $_SESSION['XNPSID']; $ret = array(); $item = array(); $formdata =& xoonips_getutility('formdata'); if (xnp_get_item($xnpsid, $item_id, $item) == RES_OK) { foreach (array('contributor' => _MD_XOONIPS_ITEM_CONTRIBUTOR_LABEL, 'description' => _MD_XOONIPS_ITEM_DESCRIPTION_LABEL, 'doi' => _MD_XOONIPS_ITEM_DOI_LABEL, 'last_update_date' => _MD_XOONIPS_ITEM_LAST_UPDATE_DATE_LABEL, 'creation_date' => _MD_XOONIPS_ITEM_CREATION_DATE_LABEL, 'item_type' => _MD_XOONIPS_ITEM_ITEM_TYPE_LABEL, 'change_logs' => _MD_XOONIPS_ITEM_CHANGELOGS_LABEL, 'lang' => _MD_XOONIPS_ITEM_LANG_LABEL) as $k => $v) { $tmp = $formdata->getValue('post', $k, 'n', false); if (!array_key_exists($k, $item) || $tmp === NULL) { continue; } if (str_replace("\r\n", "\r", $item[$k]) != str_replace("\r\n", "\r", $tmp)) { array_push($ret, $v); } } } //has been title modified ? $titles = array(); foreach (preg_split("/[\r\n]+/", $formdata->getValue('post', 'title', 's', false, '')) as $title) { if (trim($title) != '') { $titles[] = $title; } } $diff = array_diff($titles, $item['titles']); if (!empty($diff)) { //modified array_push($ret, _MD_XOONIPS_ITEM_TITLE_LABEL); } //has been keyword modified ? $keywords = $formdata->getValue('post', 'keywords', 's', false); $keywords = !empty($keywords) ? explode(",", $keywords) : array(); $diff = array_diff($keywords, $item['keywords']); if (count($keywords) != count($item['keywords']) || !empty($diff)) { //modified array_push($ret, _MD_XOONIPS_ITEM_KEYWORDS_LABEL); } //is indexes modified ? $xoonipsCheckedXID = $formdata->getValue('post', 'xoonipsCheckedXID', 's', false); if (isset($xoonipsCheckedXID)) { $new_index = explode(',', $xoonipsCheckedXID); $old_index = array(); $res = xnp_get_index_id_by_item_id($xnpsid, $item['item_id'], $old_index); if ($res == RES_OK) { if (count(array_diff($old_index, $new_index)) > 0 || count(array_diff($new_index, $old_index)) > 0) { array_push($ret, _MD_XOONIPS_ITEM_INDEX_LABEL); // if you change this label, don't forget to modify xnpUpdateBasicInformation() } } } //is related to modified ? $related_to_check = $formdata->getValueArray('post', 'related_to_check', 'i', false, null); $new_related_to = !isset($related_to_check) || $related_to_check === "" ? array() : (is_string($related_to_check) ? preg_split("/[\r\n]+/", $related_to_check) : $related_to_check); $related_to = $formdata->getValue('post', 'related_to', 's', false); $related_to = isset($related_to) ? $related_to : ""; foreach (preg_split("/[\r\n]+/", $related_to) as $id) { $tmp_item = array(); if (xnp_get_item($xnpsid, (int) $id, $tmp_item) != RES_OK) { continue; } $new_related_to[] = $id; } $old_related_to = array(); $res = xnp_get_related_to($xnpsid, $item['item_id'], $old_related_to); if ($res == RES_OK) { if (count(array_diff($old_related_to, $new_related_to)) > 0 || count(array_diff($new_related_to, $old_related_to)) > 0) { array_push($ret, _MD_XOONIPS_ITEM_RELATED_TO_LABEL); } } // get file_id of preview file before change $tmp = xnpGetFileInfo("t_file.file_id", "t_file_type.name='preview' and is_deleted=0 and sess_id is NULL ", $item_id); $old_files = array(); foreach ($tmp as $i) { $old_files[] = $i[0]; } $new_files = array(); $previewFileID = $formdata->getValue('post', 'previewFileID', 's', false); if (isset($previewFileID) && $previewFileID != '') { $new_files = explode(',', $previewFileID); } if (count(array_diff($old_files, $new_files)) > 0 || count(array_diff($new_files, $old_files)) > 0) { //preview is modified array_push($ret, _MD_XOONIPS_ITEM_PREVIEW_LABEL); } return $ret; }