changeset 21:7b6b064afe5d

add function openmindattribute_addIsmiBibIDs() to copy EndNote IDs to field_ismi_bibid.
author casties
date Fri, 18 Sep 2015 18:26:38 +0200
parents bdf91a4a40ff
children 3585573999b6
files openmindattribute/openmindattribute.module
diffstat 1 files changed, 31 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/openmindattribute/openmindattribute.module	Fri Sep 18 18:25:10 2015 +0200
+++ b/openmindattribute/openmindattribute.module	Fri Sep 18 18:26:38 2015 +0200
@@ -1465,6 +1465,37 @@
 }
 
 
+function openmindattribute_addIsmiBibIDs() {
+	# adds the EndNote identifier to the ismi_bibid field of the Biblio objects
+	$query = new EntityFieldQuery();
+
+	$query->entityCondition('entity_type', 'node')
+	->entityCondition('bundle', 'biblio');
+
+	$result = $query->execute();
+
+	if (isset($result['node'])) {
+		$nids = array_keys($result['node']);
+		$biblios = entity_load('node', $nids);
+	} else {
+		return;
+	}
+
+	foreach ($biblios as $bib) {
+	
+		$endnote_id = $bib->biblio_custom3;
+		if (isset($endnote_id)) {
+			$bib->field_ismi_bibid = ['und' => [['value' => $endnote_id]]];
+			node_save($bib);
+		}
+		//dpm($endnote_id);
+		//dpm($bib->field_ismi_bibid);
+		
+	}
+	print "Updated field_ismi_bibid for " . count($biblios) . " bibliography entries.\n";
+}
+
+
 function openmindattribute_addIDbibliographieID(){
 	#adds the add bibliographie
 	$query = new EntityFieldQuery();