tripal_pub.chado_node.inc 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143
  1. <?php
  2. /**
  3. * @file
  4. * Implements the pub node content type
  5. */
  6. /**
  7. * Implements hook_node_info().
  8. *
  9. * @ingroup tripal_pub
  10. */
  11. function tripal_pub_node_info() {
  12. return array(
  13. 'chado_pub' => array(
  14. 'name' => t('Publication'),
  15. 'base' => 'chado_pub',
  16. 'description' => t('A publication from the Chado database'),
  17. 'title_label' => t('Article Title'),
  18. 'body_label' => t('Abstract'),
  19. 'has_title' => TRUE,
  20. 'has_body' => FALSE,
  21. 'chado_node_api' => array(
  22. 'base_table' => 'pub',
  23. 'hook_prefix' => 'chado_pub',
  24. 'record_type_title' => array(
  25. 'singular' => t('Publication'),
  26. 'plural' => t('Publications')
  27. ),
  28. 'sync_filters' => array(
  29. 'type_id' => FALSE,
  30. 'organism_id' => FALSE
  31. ),
  32. ),
  33. ),
  34. );
  35. }
  36. /**
  37. * Implements hook_form().
  38. *
  39. * @ingroup tripal_pub
  40. */
  41. function chado_pub_form($node, $form_state) {
  42. $form = array();
  43. // Default values can come in the following ways:
  44. //
  45. // 1) as elements of the $node object. This occurs when editing an existing pub
  46. // 2) in the $form_state['values'] array which occurs on a failed validation or
  47. // ajax callbacks from non submit form elements
  48. // 3) in the $form_state['input'] array which occurs on ajax callbacks from submit
  49. // form elements and the form is being rebuilt
  50. //
  51. // set form field defaults
  52. $pub_id = null;
  53. $title = '';
  54. $pyear = '';
  55. $uniquename = '';
  56. $type_id = '';
  57. $is_obsolete = '';
  58. // some of the fields in the pub table should show up in the properties
  59. // form elements to make the form more seemless. We will add them
  60. // to this array.
  61. $more_props = array();
  62. // if we are editing an existing node then the pub is already part of the node
  63. if (property_exists($node, 'pub')) {
  64. $pub = $node->pub;
  65. $pub = chado_expand_var($pub, 'field', 'pub.title');
  66. $pub = chado_expand_var($pub, 'field', 'pub.volumetitle');
  67. $pub = chado_expand_var($pub, 'field', 'pub.uniquename');
  68. $pub_id = $pub->pub_id;
  69. $title = $pub->title;
  70. $pyear = $pub->pyear;
  71. $uniquename = $pub->uniquename;
  72. $type_id = $pub->type_id->cvterm_id;
  73. $is_obsolete = $pub->is_obsolete;
  74. // if the obsolete value is set by the database then it is in the form of
  75. // 't' or 'f', we need to convert to 1 or 0
  76. $is_obsolete = $is_obsolete == 't' ? 1 : $is_obsolete;
  77. $is_obsolete = $is_obsolete == 'f' ? 0 : $is_obsolete;
  78. // set the organism_id in the form
  79. $form['pub_id'] = array(
  80. '#type' => 'value',
  81. '#value' => $pub->pub_id,
  82. );
  83. // get fields from the pub table and convert them to properties. We will add these to the $more_props
  84. // array which gets passed in to the tripal_core_properties_form() API call further down
  85. if ($pub->volumetitle) {
  86. $cvterm = tripal_cv_get_cvterm_by_name('Volume Title', NULL, 'tripal_pub');
  87. $more_props[] = array('cvterm' => $cvterm, 'value' => $pub->volumetitle);
  88. }
  89. if ($pub->volume) {
  90. $cvterm = tripal_cv_get_cvterm_by_name('Volume', NULL, 'tripal_pub');
  91. $more_props[] = array('cvterm' => $cvterm, 'value' => $pub->volume);
  92. }
  93. if ($pub->series_name) {
  94. switch ($pub->type_id->name) {
  95. case 'Journal Article':
  96. $cvterm = tripal_cv_get_cvterm_by_name('Journal Name', NULL, 'tripal_pub');
  97. $more_props[] = array('cvterm' => $cvterm, 'value' => $pub->series_name);
  98. break;
  99. case 'Conference Proceedings':
  100. $cvterm = tripal_cv_get_cvterm_by_name('Conference Name', NULL, 'tripal_pub');
  101. $more_props[] = array('cvterm' => $cvterm, 'value' => $pub->series_name);
  102. break;
  103. default:
  104. $cvterm = tripal_cv_get_cvterm_by_name('Series Name', NULL, 'tripal_pub');
  105. $more_props[] = array('cvterm' => $cvterm, 'value' => $pub->series_name);
  106. }
  107. }
  108. if ($pub->issue) {
  109. $cvterm = tripal_cv_get_cvterm_by_name('Issue', NULL, 'tripal_pub');
  110. $more_props[] = array('cvterm' => $cvterm, 'value' => $pub->issue);
  111. }
  112. if ($pub->pages) {
  113. $cvterm = tripal_cv_get_cvterm_by_name('Pages', NULL, 'tripal_pub');
  114. $more_props[] = array('cvterm' => $cvterm, 'value' => $pub->pages);
  115. }
  116. if ($pub->miniref) {
  117. // not sure what to do with this one
  118. }
  119. if ($pub->publisher) {
  120. $cvterm = tripal_cv_get_cvterm_by_name('Publisher', NULL, 'tripal_pub');
  121. $more_props[] = array('cvterm' => $cvterm, 'value' => $pub->publisher);
  122. }
  123. if ($pub->pubplace) {
  124. $cvterm = tripal_cv_get_cvterm_by_name('Published Location', NULL, 'tripal_pub');
  125. $more_props[] = array('cvterm' => $cvterm, 'value' => $pub->pages);
  126. }
  127. }
  128. // if we are re constructing the form from a failed validation or ajax callback
  129. // then use the $form_state['values'] values
  130. if (array_key_exists('values', $form_state) and isset($form_state['values']['pubtitle'])) {
  131. $title = $form_state['values']['pubtitle'];
  132. $pyear = $form_state['values']['pyear'];
  133. $uniquename = $form_state['values']['uniquename'];
  134. $type_id = $form_state['values']['type_id'];
  135. $is_obsolete = $form_state['values']['is_obsolete'];
  136. }
  137. // if we are re building the form from after submission (from ajax call) then
  138. // the values are in the $form_state['input'] array
  139. if (array_key_exists('input', $form_state) and !empty($form_state['input'])) {
  140. $title = $form_state['input']['pubtitle'];
  141. $uniquename = $form_state['input']['uniquename'];
  142. $type_id = $form_state['input']['type_id'];
  143. $is_obsolete = $form_state['input']['is_obsolete'];
  144. }
  145. // a drupal title can only be 255 characters, but the Chado title can be much longer.
  146. // we use the publication title as the drupal title, but we'll need to truncate it.
  147. $form['title'] = array(
  148. '#type' => 'hidden',
  149. '#value' => substr($title, 0, 255),
  150. );
  151. $form['pubtitle'] = array(
  152. '#type' => 'textarea',
  153. '#title' => t('Publication Title'),
  154. '#default_value' => $title,
  155. '#required' => TRUE,
  156. );
  157. // get the list of publication types. In the Tripal publication
  158. // ontologies these are all grouped under the term 'Publication Type'
  159. // we want the default to be 'Journal Article'
  160. $sql = "
  161. SELECT
  162. CVTS.cvterm_id, CVTS.name
  163. FROM {cvtermpath} CVTP
  164. INNER JOIN {cvterm} CVTS ON CVTP.subject_id = CVTS.cvterm_id
  165. INNER JOIN {cvterm} CVTO ON CVTP.object_id = CVTO.cvterm_id
  166. INNER JOIN {cv} ON CVTO.cv_id = CV.cv_id
  167. WHERE
  168. CV.name = 'tripal_pub' AND CVTO.name = 'Publication Type' AND
  169. NOT CVTS.is_obsolete = 1
  170. ORDER BY CVTS.name ASC
  171. ";
  172. $results = chado_query($sql);
  173. $pub_types = array();
  174. while ($pub_type = $results->fetchObject()) {
  175. $pub_types[$pub_type->cvterm_id] = $pub_type->name;
  176. // if we don't have a default type then set the default to be 'Journal Article'
  177. if (strcmp($pub_type->name,"Journal Article") == 0 and !$type_id) {
  178. $type_id = $pub_type->cvterm_id;
  179. }
  180. }
  181. $form['type_id'] = array(
  182. '#type' => 'select',
  183. '#title' => t('Publication Type'),
  184. '#options' => $pub_types,
  185. '#required' => TRUE,
  186. '#default_value' => $type_id,
  187. );
  188. $form['pyear'] = array(
  189. '#type' => 'textfield',
  190. '#title' => t('Publication Year'),
  191. '#default_value' => $pyear,
  192. '#required' => TRUE,
  193. '#size' => 5,
  194. '#description' => t('Enter the year of publication. Also, if available, please add a <b>Publication Date</b> property to specify the full date of publication.'),
  195. );
  196. $form['uniquename'] = array(
  197. '#type' => 'textarea',
  198. '#title' => t('Citation'),
  199. '#default_value' => $uniquename,
  200. '#description' => t('All publications must have a unique citation.
  201. <b>Please enter the full citation for this publication or leave blank and one will be generated
  202. automatically if possible</b>. For PubMed style citations list
  203. the last name of the author followed by initials. Each author should be separated by a comma. Next comes
  204. the title, followed by the series title (e.g. journal name), publication date (4 digit year, 3 character Month, day), volume, issue and page numbers. You may also use HTML to provide a link in the citation.
  205. Below is an example: <pre>Medeiros PM, Ladio AH, Santos AM, Albuquerque UP. <a href="http://www.ncbi.nlm.nih.gov/pubmed/23462414" target="_blank">Does the selection of medicinal plants by Brazilian local populations
  206. suffer taxonomic influence?</a> J Ethnopharmacol. 2013 Apr 19; 146(3):842-52.</pre>'),
  207. );
  208. $form['is_obsolete'] = array(
  209. '#type' => 'checkbox',
  210. '#title' => t('Is Obsolete? (Check for Yes)'),
  211. '#default_value' => $is_obsolete,
  212. );
  213. // Properties Form
  214. // ----------------------------------
  215. // Need to pass in our own select_options since we use cvtermpath to filter ours
  216. $select_options = array();
  217. $select_options[] = 'Select a Property';
  218. $sql = "
  219. SELECT
  220. DISTINCT CVTS.cvterm_id, CVTS.name, CVTS.definition
  221. FROM {cvtermpath} CVTP
  222. INNER JOIN {cvterm} CVTS ON CVTP.subject_id = CVTS.cvterm_id
  223. INNER JOIN {cvterm} CVTO ON CVTP.object_id = CVTO.cvterm_id
  224. INNER JOIN {cv} ON CVTO.cv_id = CV.cv_id
  225. WHERE CV.name = 'tripal_pub' and
  226. (CVTO.name = 'Publication Details' OR CVTS.name = 'Publication Type') AND
  227. NOT CVTS.is_obsolete = 1
  228. ORDER BY CVTS.name ASC
  229. ";
  230. $prop_types = chado_query($sql);
  231. while ($prop = $prop_types->fetchObject()) {
  232. // add all properties except the Citation. That property is set via the uniquename field
  233. if ($prop->name != 'Citation') {
  234. $select_options[$prop->cvterm_id] = $prop->name;
  235. }
  236. }
  237. $details = array(
  238. 'property_table' => 'pubprop',
  239. 'base_foreign_key' => 'pub_id',
  240. 'base_key_value' => $pub_id,
  241. 'cv_name' => 'tripal_pub',
  242. 'select_options' => $select_options,
  243. );
  244. chado_add_node_form_properties($form, $form_state, $details);
  245. // RELATIONSHIPS FORM
  246. //---------------------------------------------
  247. // We want to use the contact_relationship_types cv if there are any terms available
  248. // and if not, to default to the relationship ontology
  249. $cv_result = chado_select_record('cv',array('cv_id'),array('name' => 'pub_relationship_types'));
  250. $cv_id = $cv_result[0]->cv_id;
  251. $select_options = tripal_cv_get_cvterm_options($cv_id);
  252. if (empty($select_options)) {
  253. $cv_result = chado_select_record('cv',array('cv_id'),array('name' => 'relationship'));
  254. $cv_id = $cv_result[0]->cv_id;
  255. $select_options = tripal_cv_get_cvterm_options($cv_id);
  256. }
  257. // D7 @TODO: tell tripal admin's about this
  258. $details = array(
  259. 'relationship_table' => 'pub_relationship', // the name of the _relationship table
  260. 'base_table' => 'pub', // the name of your chado base table
  261. 'base_foreign_key' => 'pub_id', // the name of the key in your base chado table
  262. 'base_key_value' => $pub_id, // the value of example_id for this record
  263. 'nodetype' => 'pub', // the human-readable name of your node type
  264. 'cv_name' => 'pub_relationship_types', // the cv.name of the cv governing example_relationship.type_id
  265. 'base_name_field' => 'uniquename', // the base table field you want to be used as the name
  266. 'select_options' => $select_options
  267. );
  268. // Adds the form elements to your current form
  269. chado_add_node_form_relationships($form, $form_state, $details);
  270. // ADDITIONAL DBXREFS FORM
  271. //---------------------------------------------
  272. $details = array(
  273. 'linking_table' => 'pub_dbxref', // the name of the _dbxref table
  274. 'base_foreign_key' => 'pub_id', // the name of the key in your base chado table
  275. 'base_key_value' => $pub_id // the value of pub_id for this record
  276. );
  277. // Adds the form elements to your current form
  278. chado_add_node_form_dbxrefs($form, $form_state, $details);
  279. return $form;
  280. }
  281. /**
  282. * Implements hook_validate().
  283. *
  284. * @ingroup tripal_pub
  285. */
  286. function chado_pub_validate($node, $form, &$form_state) {
  287. // get the submitted values
  288. $title = trim($node->pubtitle);
  289. $pyear = trim($node->pyear);
  290. $uniquename = trim($node->uniquename);
  291. $is_obsolete = $node->is_obsolete;
  292. $type_id = $node->type_id;
  293. // if this is a delete then don't validate
  294. if($node->op == 'Delete') {
  295. return;
  296. }
  297. // we are syncing if we do not have a node ID but we do have a pub_id. We don't
  298. // need to validate during syncing so just skip it.
  299. if (is_null($node->nid) and property_exists($node, 'pub_id') and $node->pub_id != 0) {
  300. return;
  301. }
  302. $pub = array();
  303. // make sure the year is four digits
  304. if(!preg_match('/^\d{4}$/', $pyear)){
  305. form_set_error('pyear', t('The publication year should be a 4 digit year.'));
  306. return;
  307. }
  308. // get the type of publication
  309. $values = array('cvterm_id' => $type_id);
  310. $options = array('statement_name' => 'sel_pub_ty');
  311. $cvterm = chado_select_record('cvterm', array('name'), $values, $options);
  312. if (count($cvterm) == 0) {
  313. $message = t('Invalid publication type.');
  314. form_set_error('type_id', $message);
  315. return;
  316. }
  317. // get the media name looking at the properties
  318. $series_name = '';
  319. foreach ($node as $element => $value) {
  320. // if this is an existing property (either previously in the database or
  321. // added via AHAH/AJAX callback)
  322. if (preg_match('/^prop_value-(\d+)-(\d+)$/', $element, $matches)) {
  323. $prop_type_id = $matches[1];
  324. $prop_type = tripal_cv_get_cvterm_by_id($prop_type_id);
  325. if($prop_type->name == 'Conference Name' or $prop_type->name == 'Journal Name') {
  326. $series_name = $value;
  327. }
  328. if($prop_type->name == 'Citation') {
  329. $uniquename = $value;
  330. }
  331. $pub[$prop_type->name] = $value;
  332. }
  333. // if this is a new property (added by this submit of the form)
  334. elseif ($element == 'new_id') {
  335. $prop_type = tripal_cv_get_cvterm_by_id($value);
  336. if($prop_type->name == 'Conference Name' or $prop_type->name == 'Journal Name') {
  337. $series_name = $node->new_value;
  338. }
  339. if($prop_type->name == 'Citation') {
  340. $uniquename = $node->new_value;
  341. }
  342. $pub[$prop_type->name] = $node->new_value;
  343. }
  344. }
  345. // if the citation is missing then try to generate one
  346. if (!$uniquename) {
  347. $pub['Title'] = $title;
  348. $pub['Publication Type'][0] = $cvterm[0]->name;
  349. $pub['Year'] = $pyear;
  350. $uniquename = tripal_pub_create_citation($pub);
  351. if (!$uniquename) {
  352. form_set_error('uniquename', "Cannot automatically generate a citation for this publication type. Please add one manually.");
  353. }
  354. }
  355. $skip_duplicate_check = 0;
  356. // if this publication is a Patent then skip the validation below. Patents can have the title
  357. // name and year but be different
  358. if (strcmp($cvterm[0]->name,'Patent') == 0) {
  359. $skip_duplicate_check = 1;
  360. }
  361. // Validating for an update
  362. if (!is_null($node->nid)) {
  363. $pub_id = $node->pub_id;
  364. // first get the original title, type and year before it was changed
  365. $values = array('pub_id' => $pub_id);
  366. $columns = array('title', 'pyear', 'type_id', 'series_name');
  367. $options = array('statement_name' => 'sel_pub_id');
  368. $pub = chado_select_record('pub', $columns, $values, $options);
  369. // if the title, type, year or series_name have changed then check the pub
  370. // to see if it is a duplicate of another
  371. if((strcmp(strtolower($pub[0]->title), strtolower($title)) == 0) and
  372. (strcmp(strtolower($pub[0]->series_name), strtolower($series_name)) == 0) and
  373. ($pub[0]->type_id == $type_id) and
  374. ($pub[0]->pyear == $pyear)) {
  375. $skip_duplicate_check = 1;
  376. }
  377. // check to see if a duplicate publication already exists
  378. if (!$skip_duplicate_check) {
  379. chado_pub_validate_check_duplicate($title, $pyear, $series_name, $cvterm, $pub_id);
  380. }
  381. chado_pub_validate_check_uniquename($uniquename, $pub_id);
  382. }
  383. // Validating for an insert
  384. else {
  385. chado_pub_validate_check_duplicate($title, $pyear, $series_name, $cvterm);
  386. chado_pub_validate_check_uniquename($uniquename);
  387. }
  388. }
  389. /**
  390. * Validate the publication uniquename. To be called from hook_validate().
  391. *
  392. * @param $uniquename
  393. * The uniquename of the publication
  394. *
  395. * @ingroup tripal_pub
  396. */
  397. function chado_pub_validate_check_uniquename($uniquename, $pub_id = NULL) {
  398. $results = tripal_pub_get_pub_by_uniquename($uniquename);
  399. // make sure we don't capture our pub_id in the list (remove it)
  400. foreach ($results as $index => $found_pub_id) {
  401. if($found_pub_id == $pub_id){
  402. unset($results[$index]);
  403. }
  404. }
  405. if (count($results) > 0) {
  406. $message = t('A publication with this unique citation already exists.');
  407. form_set_error('uniquename', $message);
  408. }
  409. }
  410. /**
  411. * Check for duplicate publications. To be called from hook_validate().
  412. *
  413. * @param $title
  414. * The title of the publication
  415. * @param $pyear
  416. * The year the publication was published
  417. * @param $series_name
  418. * The series name of the publication
  419. * @param $cvterm
  420. * The type of publication
  421. * @param $pub_id
  422. * the unique id of the publication
  423. *
  424. * @ingroup tripal_pub
  425. */
  426. function chado_pub_validate_check_duplicate($title, $pyear, $series_name, $cvterm, $pub_id = NULL) {
  427. // make sure the publication is unique using the prefereed import duplication check
  428. $import_dups_check = variable_get('tripal_pub_import_duplicate_check', 'title_year_media');
  429. switch ($import_dups_check) {
  430. case 'title_year':
  431. $results = tripal_pub_get_pubs_by_title_type_pyear_series($title, NULL, $pyear, NULL);
  432. // make sure we don't capture our pub_id in the list (remove it)
  433. foreach ($results as $index => $found_pub_id) {
  434. if($found_pub_id == $pub_id){
  435. unset($results[$index]);
  436. }
  437. }
  438. if (count($results) > 0) {
  439. $message = t('A publication with this title and publication year, already exists.');
  440. form_set_error('pyear', $message);
  441. }
  442. break;
  443. case 'title_year_type':
  444. $results = tripal_pub_get_pubs_by_title_type_pyear_series($title, $cvterm[0]->name, $pyear, NULL);
  445. // make sure we don't capture our pub_id in the list (remove it)
  446. foreach ($results as $index => $found_pub_id) {
  447. if($found_pub_id == $pub_id){
  448. unset($results[$index]);
  449. }
  450. }
  451. if (count($results) > 0) {
  452. $message = t('A publication with this title, type and publication year, already exists.');
  453. form_set_error('pyear', $message);
  454. }
  455. break;
  456. case 'title_year_media':
  457. $results = tripal_pub_get_pubs_by_title_type_pyear_series($title, NULL, $pyear, $series_name);
  458. // make sure we don't capture our pub_id in the list (remove it)
  459. foreach ($results as $index => $found_pub_id) {
  460. if($found_pub_id == $pub_id){
  461. unset($results[$index]);
  462. }
  463. }
  464. if (count($results) > 0) {
  465. $message = t('A publication with this title, media name (e.g. Journal Name) and publication year, already exists.');
  466. form_set_error('pyear', $message);
  467. }
  468. break;
  469. }
  470. }
  471. /**
  472. * Implement hook_node_access().
  473. *
  474. * This hook allows node modules to limit access to the node types they define.
  475. *
  476. * @param $node
  477. * The node on which the operation is to be performed, or, if it does not yet exist, the
  478. * type of node to be created
  479. *
  480. * @param $op
  481. * The operation to be performed
  482. *
  483. * @param $account
  484. * A user object representing the user for whom the operation is to be performed
  485. *
  486. * @return
  487. * If the permission for the specified operation is not set then return FALSE. If the
  488. * permission is set then return NULL as this allows other modules to disable
  489. * access. The only exception is when the $op == 'create'. We will always
  490. * return TRUE if the permission is set.
  491. *
  492. * @ingroup tripal_pub
  493. */
  494. function chado_pub_node_access($node, $op, $account) {
  495. if ($op == 'create') {
  496. if (!user_access('create chado_pub content', $account)) {
  497. return FALSE;
  498. }
  499. return TRUE;
  500. }
  501. if ($op == 'update') {
  502. if (!user_access('edit chado_pub content', $account)) {
  503. return FALSE;
  504. }
  505. }
  506. if ($op == 'delete') {
  507. if (!user_access('delete chado_pub content', $account)) {
  508. return FALSE;
  509. }
  510. }
  511. if ($op == 'view') {
  512. if (!user_access('access chado_pub content', $account)) {
  513. return FALSE;
  514. }
  515. }
  516. return NULL;
  517. }
  518. /**
  519. * Implements hook_insert().
  520. *
  521. * @ingroup tripal_pub
  522. */
  523. function chado_pub_insert($node) {
  524. $title = trim($node->pubtitle);
  525. $pyear = trim($node->pyear);
  526. $uniquename = trim($node->uniquename);
  527. $is_obsolete = $node->is_obsolete;
  528. $type_id = $node->type_id;
  529. // we need an array suitable for the tripal_pub_create_citation() function
  530. // to automatically generate a citation if a uniquename doesn't already exist
  531. $pub_arr = array();
  532. // if there is an pub_id in the $node object then this must be a sync so
  533. // we can skip adding the pub as it is already there, although
  534. // we do need to proceed with the rest of the insert
  535. if (!property_exists($node, 'pub_id')) {
  536. $properties = array(); // stores all of the properties we need to add
  537. $cross_refs = array(); // stores any cross references for this publication
  538. // get the properties from the form
  539. $properties = chado_retrieve_node_form_properties($node);
  540. // get the list of properties for easy lookup (without doing lots of database queries
  541. $properties_list = array();
  542. $sql = "
  543. SELECT CVTS.cvterm_id, CVTS.name, CVTS.definition
  544. FROM {cvtermpath} CVTP
  545. INNER JOIN {cvterm} CVTS ON CVTP.subject_id = CVTS.cvterm_id
  546. INNER JOIN {cvterm} CVTO ON CVTP.object_id = CVTO.cvterm_id
  547. INNER JOIN {cv} ON CVTO.cv_id = CV.cv_id
  548. WHERE CV.name = 'tripal_pub' and CVTO.name = 'Publication Details' and
  549. NOT CVTS.is_obsolete = 1
  550. ORDER BY CVTS.name ASC
  551. ";
  552. $prop_types = chado_query($sql);
  553. while ($prop = $prop_types->fetchObject()) {
  554. $properties_list[$prop->cvterm_id] = $prop->name;
  555. // The 'Citation' term is special because it serves
  556. // both as a property and as the uniquename for the
  557. // pub and we want it stored in both the pub table and the pubprop table
  558. if ($prop->name == 'Citation') {
  559. $citation_id = $prop->cvterm_id;
  560. if (!empty($node->uniquename)) {
  561. $properties[$citation_id] = $node->uniquename;
  562. }
  563. }
  564. }
  565. // iterate through all of the properties and remove those that really are
  566. // part of the pub table fields
  567. $volume = '';
  568. $volumetitle = '';
  569. $issue = '';
  570. $pages = '';
  571. $publisher = '';
  572. $series_name = '';
  573. $pubplace = '';
  574. $miniref = '';
  575. $cross_refs = array();
  576. foreach ($properties as $type_id => $element) {
  577. $value = trim($element[0]);
  578. $name = $properties_list[$type_id];
  579. // populate our $pub_array for building a citation
  580. $pub_arr[$name] = $value;
  581. // remove properties that are stored in the pub table
  582. if ($name == "Volume") {
  583. $volume = $value;
  584. unset($properties[$type_id]);
  585. }
  586. elseif ($name == "Volume Title") {
  587. $volumetitle = $value;
  588. unset($properties[$type_id]);
  589. }
  590. elseif ($name == "Issue") {
  591. $issue = $value;
  592. unset($properties[$type_id]);
  593. }
  594. elseif ($name == "Pages") {
  595. $pages = $value;
  596. unset($properties[$type_id]);
  597. }
  598. elseif ($name == "Publisher") {
  599. $publisher = $value;
  600. unset($properties[$type_id]);
  601. }
  602. elseif ($name == "Series Name" or $name == "Journal Name" or $name == "Conference Name") {
  603. $series_name = $value;
  604. unset($properties[$type_id]);
  605. }
  606. elseif ($name == "Journal Country" or $name == "Published Location") {
  607. $pubplace = $value;
  608. // allow this property to go into the pubprop table so we don't loose info
  609. // so don't unset it. But it will also go into the pub.pubplace field
  610. }
  611. elseif ($name == "Publication Dbxref") {
  612. // we will add the cross-references to the pub_dbxref table
  613. // but we also want to keep the property in the pubprop table so don't unset it
  614. $cross_refs[] = $value;
  615. }
  616. }
  617. // generate a citation for this pub if one doesn't already exist
  618. if (!$node->uniquename and !array_key_exists($citation_id, $properties)) {
  619. $pub_type = tripal_cv_get_cvterm_by_id($node->type_id);
  620. $pub_arr['Title'] = $node->pubtitle;
  621. $pub_arr['Publication Type'][0] = $pub_type->name;
  622. $pub_arr['Year'] = $node->pyear;
  623. $node->uniquename = tripal_pub_create_citation($pub_arr);
  624. $properties[$citation_id][0] = $node->uniquename;
  625. }
  626. // insert the pub record
  627. $values = array(
  628. 'title' => $node->pubtitle,
  629. 'series_name' => substr($series_name, 0, 255),
  630. 'type_id' => $node->type_id,
  631. 'pyear' => $node->pyear,
  632. 'is_obsolete' => $node->is_obsolete ? 'true' : 'false',
  633. 'uniquename' => $node->uniquename,
  634. 'volumetitle' => $volumetitle,
  635. 'volume' => $volume,
  636. 'issue' => $issue,
  637. 'pages' => $pages,
  638. 'miniref' => substr($miniref, 0, 255),
  639. 'publisher' => substr($publisher, 0, 255),
  640. 'pubplace' => substr($pubplace, 0, 255),
  641. );
  642. $pub = chado_insert_record('pub', $values);
  643. if (!$pub) {
  644. drupal_set_message("Error inserting publication", "error");
  645. watchdog('tripal_pub', "Error inserting publication", array(), WATCHDOG_ERROR);
  646. return;
  647. }
  648. $pub_id = $pub['pub_id'];
  649. // now add in the properties
  650. // Only adds in those not used in the pub record
  651. $details = array(
  652. 'property_table' => 'pubprop',
  653. 'base_table' => 'pub',
  654. 'foreignkey_name' => 'pub_id',
  655. 'foreignkey_value' => $pub_id
  656. );
  657. chado_update_node_form_properties($node, $details, $properties);
  658. // * Relationships Form *
  659. $details = array(
  660. 'relationship_table' => 'pub_relationship', // name of the _relationship table
  661. 'foreignkey_value' => $pub_id // value of the pub_id key
  662. );
  663. chado_update_node_form_relationships($node, $details);
  664. // add in any database cross-references
  665. foreach ($cross_refs as $index => $ref) {
  666. $pub_dbxref = tripal_pub_add_pub_dbxref($pub['pub_id'], trim($ref));
  667. if (!$pub_dbxref) {
  668. drupal_set_message("Error cannot add publication cross reference: $ref", "error");
  669. watchdog('tripal_pub', "Error cannot add publication cross reference: %ref",
  670. array('%ref' => $ref), WATCHDOG_ERROR);
  671. }
  672. }
  673. // * Additional DBxrefs Form *
  674. $details = array(
  675. 'linking_table' => 'pub_dbxref', // the name of your _dbxref table
  676. 'foreignkey_name' => 'pub_id', // the name of the key in your base table
  677. 'foreignkey_value' => $pub_id // the value of the pub_id key
  678. );
  679. chado_update_node_form_dbxrefs($node, $details);
  680. }
  681. else {
  682. $pub_id = $node->pub_id;
  683. }
  684. // Make sure the entry for this pub doesn't already exist in the
  685. // chado_pub table if it doesn't exist then we want to add it.
  686. $check_org_id = chado_get_id_from_nid('pub', $node->nid);
  687. if (!$check_org_id) {
  688. $record = new stdClass();
  689. $record->nid = $node->nid;
  690. $record->vid = $node->vid;
  691. $record->pub_id = $pub_id;
  692. drupal_write_record('chado_pub', $record);
  693. }
  694. }
  695. /**
  696. * Implements hook_update().
  697. *
  698. * The purpose of the function is to allow the module to take action when an edited node is being
  699. * updated. It updates any name changes to the database tables that werec reated upon registering a Publication.
  700. * As well, the database will be changed, so the user changed information will be saved to the database.
  701. *
  702. * @param $node
  703. * The node being updated
  704. *
  705. * @ingroup tripal_pub
  706. */
  707. function chado_pub_update($node) {
  708. $title = trim($node->pubtitle);
  709. $pyear = trim($node->pyear);
  710. $uniquename = trim($node->uniquename);
  711. $is_obsolete = $node->is_obsolete;
  712. $type_id = $node->type_id;
  713. // we need an array suitable for the tripal_pub_create_citation() function
  714. // to automatically generate a citation if a uniquename doesn't already exist
  715. $pub_arr = array();
  716. // get the publication ID for this publication
  717. $pub_id = chado_get_id_from_nid('pub', $node->nid) ;
  718. $properties = array(); // stores all of the properties we need to add
  719. $cross_refs = array(); // stores any cross references for this publication
  720. // get the properties from the form
  721. $properties = chado_retrieve_node_form_properties($node);
  722. // get the list of properties for easy lookup (without doing lots of database queries
  723. $properties_list = array();
  724. $sql = "
  725. SELECT DISTINCT CVTS.cvterm_id, CVTS.name, CVTS.definition
  726. FROM {cvtermpath} CVTP
  727. INNER JOIN {cvterm} CVTS ON CVTP.subject_id = CVTS.cvterm_id
  728. INNER JOIN {cvterm} CVTO ON CVTP.object_id = CVTO.cvterm_id
  729. INNER JOIN {cv} ON CVTO.cv_id = CV.cv_id
  730. WHERE CV.name = 'tripal_pub' and
  731. (CVTO.name = 'Publication Details' or CVTS.name = 'Publication Type') and
  732. NOT CVTS.is_obsolete = 1
  733. ORDER BY CVTS.name ASC
  734. ";
  735. $prop_types = chado_query($sql);
  736. while ($prop = $prop_types->fetchObject()) {
  737. $properties_list[$prop->cvterm_id] = $prop->name;
  738. // The 'Citation' term is special because it serves
  739. // both as a property and as the uniquename for the
  740. // pub and we want it stored in both the pub table and the pubprop table
  741. if ($prop->name == 'Citation') {
  742. $citation_id = $prop->cvterm_id;
  743. if (!empty($node->uniquename)) {
  744. $properties[$citation_id][0] = $node->uniquename;
  745. }
  746. }
  747. }
  748. // iterate through all of the properties and remove those that really are
  749. // part of the pub table fields
  750. $volume = '';
  751. $volumetitle = '';
  752. $issue = '';
  753. $pages = '';
  754. $publisher = '';
  755. $series_name = '';
  756. $pubplace = '';
  757. $miniref = '';
  758. $cross_refs = array();
  759. foreach ($properties as $type_id => $element) {
  760. foreach ($element as $index => $value) {
  761. $name = $properties_list[$type_id];
  762. // populate our $pub_array for building a citation
  763. $pub_arr[$name] = $value;
  764. // remove properties that are stored in the pub table
  765. if ($name == "Volume") {
  766. $volume = $value;
  767. unset($properties[$type_id]);
  768. }
  769. elseif ($name == "Volume Title") {
  770. $volumetitle = $value;
  771. unset($properties[$type_id]);
  772. }
  773. elseif ($name == "Issue") {
  774. $issue = $value;
  775. unset($properties[$type_id]);
  776. }
  777. elseif ($name == "Pages") {
  778. $pages = $value;
  779. unset($properties[$type_id]);
  780. }
  781. elseif ($name == "Publisher") {
  782. $publisher = $value;
  783. unset($properties[$type_id]);
  784. }
  785. elseif ($name == "Journal Name" or $name == "Conference Name") {
  786. $series_name = $value;
  787. unset($properties[$type_id]);
  788. }
  789. elseif ($name == "Journal Country" or $name == "Published Location") {
  790. $pubplace = $value;
  791. // allow this property to go into the pubprop table so we don't loose info
  792. // so don't unset it. But it will also go into the pub.pubplace field
  793. }
  794. elseif ($name == "Publication Dbxref") {
  795. // we will add the cross-references to the pub_dbxref table
  796. // but we also want to keep the property in the pubprop table so don't unset it
  797. $cross_refs[] = $value;
  798. }
  799. }
  800. }
  801. // generate a citation for this pub if one doesn't already exist
  802. if (!$node->uniquename) {
  803. $pub_type = tripal_cv_get_cvterm_by_id($node->type_id);
  804. $pub_arr['Title'] = $node->pubtitle;
  805. $pub_arr['Publication Type'][0] = $pub_type->name;
  806. $pub_arr['Year'] = $node->pyear;
  807. $node->uniquename = tripal_pub_create_citation($pub_arr);
  808. $properties[$citation_id][0] = $node->uniquename;
  809. }
  810. // update the pub record
  811. $match = array(
  812. 'pub_id' => $pub_id,
  813. );
  814. $values = array(
  815. 'title' => $node->pubtitle,
  816. 'type_id' => $node->type_id,
  817. 'pyear' => $node->pyear,
  818. 'is_obsolete' => $node->is_obsolete ? 'true' : 'false',
  819. 'uniquename' => $node->uniquename,
  820. 'series_name' => substr($series_name, 0, 255),
  821. 'volumetitle' => $volumetitle,
  822. 'volume' => $volume,
  823. 'issue' => $issue,
  824. 'pages' => $pages,
  825. 'miniref' => substr($miniref, 0, 255),
  826. 'publisher' => substr($publisher, 0, 255),
  827. 'pubplace' => substr($pubplace, 0, 255),
  828. );
  829. $status = chado_update_record('pub', $match, $values);
  830. if (!$status) {
  831. drupal_set_message("Error updating publication", "error");
  832. watchdog('tripal_pub', "Error updating publication", array(), WATCHDOG_ERROR);
  833. return;
  834. }
  835. // now add in the properties by first removing any the publication
  836. // already has and adding the ones we have
  837. $details = array(
  838. 'property_table' => 'pubprop',
  839. 'base_table' => 'pub',
  840. 'foreignkey_name' => 'pub_id',
  841. 'foreignkey_value' => $pub_id
  842. );
  843. chado_update_node_form_properties($node, $details, $properties);
  844. // * Relationships Form *
  845. $details = array(
  846. 'relationship_table' => 'pub_relationship', // name of the _relationship table
  847. 'foreignkey_value' => $pub_id // value of the pub_id key
  848. );
  849. chado_update_node_form_relationships($node, $details);
  850. // add in any database cross-references after first removing
  851. chado_delete_record('pub_dbxref', array('pub_id' => $pub_id));
  852. foreach ($cross_refs as $index => $ref) {
  853. $pub_dbxref = tripal_pub_add_pub_dbxref($pub_id, trim($ref));
  854. if (!$pub_dbxref) {
  855. drupal_set_message("Error cannot add publication cross reference: $ref", "error");
  856. watchdog('tripal_pub', "Error cannot add publication cross reference: %ref",
  857. array('%ref' => $ref), WATCHDOG_ERROR);
  858. }
  859. }
  860. // * Additional DBxrefs Form *
  861. $details = array(
  862. 'linking_table' => 'pub_dbxref', // the name of your _dbxref table
  863. 'foreignkey_name' => 'pub_id', // the name of the key in your base table
  864. 'foreignkey_value' => $pub_id // the value of the pub_id key
  865. );
  866. chado_update_node_form_dbxrefs($node, $details);
  867. }
  868. /**
  869. * Implements hook_load().
  870. *
  871. * @param $node
  872. * The node that is to be loaded
  873. *
  874. * @return $node
  875. * The node with the information to be loaded into the database
  876. *
  877. * @ingroup tripal_pub
  878. */
  879. function chado_pub_load($nodes) {
  880. foreach ($nodes as $nid => $node) {
  881. // find the pub and add in the details
  882. $pub_id = chado_get_id_from_nid('pub', $nid);
  883. // get the pub
  884. $values = array('pub_id' => $pub_id);
  885. $pub = chado_generate_var('pub', $values);
  886. // expand the 'text' fields as those aren't included by default
  887. // and they really shouldn't be so large to cause problems
  888. $pub = chado_expand_var($pub, 'field', 'pub.title');
  889. $pub = chado_expand_var($pub, 'field', 'pub.volumetitle');
  890. $pub = chado_expand_var($pub, 'field', 'pub.uniquename');
  891. // set the URL path
  892. $nodes[$nid]->path = "pub/$pub_id";
  893. $nodes[$nid]->pub = $pub;
  894. }
  895. }
  896. /**
  897. * Implements hook_delete().
  898. *
  899. * This function takes a node and if the delete button has been chosen by the user, the publication
  900. * and it's details will be removed.Following,given the node-ID, the instance will be deleted from
  901. * the 'chado_pub' table.
  902. *
  903. * @parm $node
  904. * Then node to be deleted
  905. *
  906. * @ingroup tripal_pub
  907. */
  908. function chado_pub_delete(&$node) {
  909. $pub_id = chado_get_id_from_nid('pub', $node->nid);
  910. // if we don't have a pub id for this node then this isn't a node of
  911. // type chado_pub or the entry in the chado_pub table was lost.
  912. if (!$pub_id) {
  913. return;
  914. }
  915. // Remove data from {chado_pub}, {node} and {node_revision} tables of
  916. // drupal database
  917. $sql_del = "DELETE FROM {chado_pub} WHERE nid = :nid AND vid = :vid";
  918. db_query($sql_del, array(':nid' => $node->nid, ':vid' => $node->vid));
  919. $sql_del = "DELETE FROM {node_revision} WHERE nid = :nid AND vid = :vid";
  920. db_query($sql_del, array(':nid' => $node->nid, ':vid' => $node->vid));
  921. $sql_del = "DELETE FROM {node} WHERE nid = :nid AND vid = :vid";
  922. db_query($sql_del, array(':nid' => $node->nid, ':vid' => $node->vid));
  923. // Remove data from pub and pubprop tables of chado database as well
  924. chado_query("DELETE FROM {pubprop} WHERE pub_id = :pub_id", array(':pub_id' => $pub_id));
  925. chado_query("DELETE FROM {pub} WHERE pub_id = :pub_id", array(':pub_id' => $pub_id));
  926. }
  927. /**
  928. * Implements hook_node_view(). Acts on all content types.
  929. *
  930. * @ingroup tripal_pub
  931. */
  932. function tripal_pub_node_view($node, $view_mode, $langcode) {
  933. switch ($node->type) {
  934. case 'chado_pub':
  935. // Show feature browser and counts
  936. if ($view_mode == 'full') {
  937. $node->content['tripal_pub_authors'] = array(
  938. '#markup' => theme('tripal_pub_authors', array('node' => $node)),
  939. '#tripal_toc_id' => 'authors',
  940. '#tripal_toc_title' => 'Author Details',
  941. );
  942. $node->content['tripal_pub_base'] = array(
  943. '#markup' => theme('tripal_pub_base', array('node' => $node)),
  944. '#tripal_toc_id' => 'base',
  945. '#tripal_toc_title' => 'Overview',
  946. '#weight' => -100,
  947. );
  948. $node->content['tripal_pub_featuremaps'] = array(
  949. '#markup' => theme('tripal_pub_featuremaps', array('node' => $node)),
  950. '#tripal_toc_id' => 'featuremaps',
  951. '#tripal_toc_title' => 'Maps',
  952. );
  953. $node->content['tripal_pub_features'] = array(
  954. '#markup' => theme('tripal_pub_features', array('node' => $node)),
  955. '#tripal_toc_id' => 'features',
  956. '#tripal_toc_title' => 'Features',
  957. );
  958. $node->content['tripal_pub_libraries'] = array(
  959. '#markup' => theme('tripal_pub_libraries', array('node' => $node)),
  960. '#tripal_toc_id' => 'libraries',
  961. '#tripal_toc_title' => 'Libraries',
  962. );
  963. $node->content['tripal_pub_projects'] = array(
  964. '#markup' => theme('tripal_pub_projects', array('node' => $node)),
  965. '#tripal_toc_id' => 'projects',
  966. '#tripal_toc_title' => 'Projects',
  967. );
  968. $node->content['tripal_pub_properties'] = array(
  969. '#markup' => theme('tripal_pub_properties', array('node' => $node)),
  970. '#tripal_toc_id' => 'properties',
  971. '#tripal_toc_title' => 'Properties',
  972. );
  973. $node->content['tripal_pub_references'] = array(
  974. '#markup' => theme('tripal_pub_references', array('node' => $node)),
  975. '#tripal_toc_id' => 'references',
  976. '#tripal_toc_title' => 'Cross References',
  977. );
  978. $node->content['tripal_pub_relationships'] = array(
  979. '#markup' => theme('tripal_pub_relationships', array('node' => $node)),
  980. '#tripal_toc_id' => 'relationships',
  981. '#tripal_toc_title' => 'Relationships',
  982. );
  983. $node->content['tripal_pub_stocks'] = array(
  984. '#markup' => theme('tripal_pub_stocks', array('node' => $node)),
  985. '#tripal_toc_id' => 'stocks',
  986. '#tripal_toc_title' => 'Stocks',
  987. );
  988. }
  989. if ($view_mode == 'teaser') {
  990. $node->content['tripal_pub_teaser'] = array(
  991. '#markup' => theme('tripal_pub_teaser', array('node' => $node)),
  992. );
  993. }
  994. break;
  995. }
  996. }
  997. /**
  998. * Implements hook_node_insert(). Acts on all content types.
  999. *
  1000. * We want the publications to always have a URL of http://[base url]/pub/[pub id]
  1001. * where [pub id] is the Chado publication ID. This will allow for easy linking
  1002. * into the publication without needing to know the node. Of course if you know the
  1003. * node that will still work too (e.g. http://[base url]/node/[node id]
  1004. * so the nodeapi function ensures that the URL path is set after insert or update
  1005. * of the node and when the node is loaded if it hasn't yet been set.
  1006. *
  1007. * @ingroup tripal_pub
  1008. */
  1009. function tripal_pub_node_insert($node) {
  1010. if ($node->type == 'chado_pub') {
  1011. $pub_id = chado_get_id_from_nid('pub', $node->nid);
  1012. tripal_pub_set_pub_url($node, $pub_id);
  1013. }
  1014. }
  1015. /**
  1016. * Implements hook_node_load(). Acts on all content types.
  1017. *
  1018. * We want the publications to always have a URL of http://[base url]/pub/[pub id]
  1019. * where [pub id] is the Chado publication ID. This will allow for easy linking
  1020. * into the publication without needing to know the node. Of course if you know the
  1021. * node that will still work too (e.g. http://[base url]/node/[node id]
  1022. * so the nodeapi function ensures that the URL path is set after insert or update
  1023. * of the node and when the node is loaded if it hasn't yet been set.
  1024. *
  1025. * @ingroup tripal_pub
  1026. */
  1027. function tripal_pub_node_load($nodes, $types) {
  1028. if (count(array_intersect(array('chado_pub'), $types))) {
  1029. foreach ($nodes as $nid => $node) {
  1030. if ($node->type == 'chado_pub' and !property_exists($node, 'path')) {
  1031. $pub_id = chado_get_id_from_nid('pub', $node->nid);
  1032. $path = tripal_pub_set_pub_url($node, $pub_id);
  1033. }
  1034. }
  1035. }
  1036. }
  1037. /**
  1038. * Implements hook_node_update(). Acts on all content types.
  1039. *
  1040. * We want the publications to always have a URL of http://[base url]/pub/[pub id]
  1041. * where [pub id] is the Chado publication ID. This will allow for easy linking
  1042. * into the publication without needing to know the node. Of course if you know the
  1043. * node that will still work too (e.g. http://[base url]/node/[node id]
  1044. * so the nodeapi function ensures that the URL path is set after insert or update
  1045. * of the node and when the node is loaded if it hasn't yet been set.
  1046. *
  1047. * @ingroup tripal_pub
  1048. */
  1049. function tripal_pub_node_update($node) {
  1050. if ($node->type == 'chado_pub') {
  1051. $pub_id = chado_get_id_from_nid('pub', $node->nid);
  1052. tripal_pub_set_pub_url($node, $pub_id);
  1053. }
  1054. }