array( 'name' => t('Publication'), 'module' => 'chado_pub', 'description' => t('A publication from the Chado database'), 'title_label' => t('Article Title'), 'body_label' => t('Abstract'), 'has_title' => TRUE, 'has_body' => FALSE, ), ); } /** * Tripal-Publication-Menu * * Implemets hook_menu(): Adds menu items for the tripal_pub module menu. This section * gives the outline for the main menu of the Tripal-Publication module * * @return * An array of menu items that is visible within the Drupal Menu, returned as soon * as the program is ran */ function tripal_pub_menu() { $items = array(); $items['find/publications' ]= array( 'title' => 'Publication Search', 'description' => ('Search for publications'), 'page callback' => 'tripal_pub_search_page', 'access arguments' => array('access chado_pub content'), 'type' => MENU_CALLBACK ); $items['find/publications/criteria/%/%'] = array( 'page callback' => 'tripal_pub_search_page_update_criteria', 'page arguments' => array(5, 6), 'access arguments' => array('access chado_pub content'), 'type ' => MENU_CALLBACK, ); $items['admin/tripal/tripal_pub']= array( 'title' => 'Publications', 'description' => ('A module for interfacing the GMOD chado database with Drupal, providing viewing of publications'), 'page callback' => 'theme', 'page arguments' => array('tripal_pub_admin'), 'access arguments' => array('administer tripal pubs'), 'type' => MENU_NORMAL_ITEM ); $items['admin/tripal/tripal_pub/configuration'] = array( 'title' => 'Configuration', 'description' => 'Configure the Tripal publication module.', 'page callback' => 'drupal_get_form', 'page arguments' => array('tripal_pub_admin'), 'access arguments' => array('administer tripal pubs'), 'type' => MENU_NORMAL_ITEM, ); $items['admin/tripal/tripal_pub/sync'] = array( 'title' => ' Sync Publications', 'description' => 'Sync publications in Chado with Drupal', 'page callback' => 'drupal_get_form', 'page arguments' => array('tripal_pub_sync_form'), 'access arguments' => array('administer tripal pubs'), 'type' => MENU_NORMAL_ITEM, ); $items['admin/tripal/tripal_pub/import_list'] = array( 'title' => t('Importers List'), 'description' => t('List all publication importers'), 'page callback' => 'tripal_pub_importers_list', 'access arguments' => array('administer tripal pubs'), 'type ' => MENU_CALLBACK, ); $items['admin/tripal/tripal_pub/import/new'] = array( 'title' => t('Add an Importer'), 'description' => t('Add a new publication importer.'), 'page callback' => 'tripal_pub_importer_setup', 'page arguments' => array(4, NULL), 'access arguments' => array('administer tripal pubs'), 'type ' => MENU_CALLBACK, ); $items['admin/tripal/tripal_pub/import/raw/%'] = array( 'page callback' => 'tripal_pub_get_raw_data', 'page arguments' => array(5), 'access arguments' => array('administer tripal pubs'), 'type ' => MENU_CALLBACK, ); $items['admin/tripal/tripal_pub/import/edit/%'] = array( 'page callback' => 'tripal_pub_importer_setup', 'page arguments' => array(4, 5), 'access arguments' => array('administer tripal pubs'), 'type ' => MENU_CALLBACK, ); $items['admin/tripal/tripal_pub/import/delete/%'] = array( 'page callback' => 'tripal_pub_importer_delete', 'page arguments' => array(5), 'access arguments' => array('administer tripal pubs'), 'type ' => MENU_CALLBACK, ); $items['admin/tripal/tripal_pub/import/changedb'] = array( 'page callback' => 'tripal_pub_importer_setup_page_update_remotedb', 'page arguments' => array(), 'access arguments' => array('administer tripal pubs'), 'type ' => MENU_CALLBACK, ); $items['admin/tripal/tripal_pub/import/criteria/%/%'] = array( 'page callback' => 'tripal_pub_importer_setup_page_update_criteria', 'page arguments' => array(5, 6), 'access arguments' => array('administer tripal pubs'), 'type ' => MENU_CALLBACK, ); $items['tripal_pub/properties/add'] = array( 'page callback' => 'tripal_pub_property_add', 'access arguments' => array('edit chado_pub content'), 'type ' => MENU_CALLBACK, ); $items['tripal_pub/properties/description'] = array( 'page callback' => 'tripal_pub_property_get_description', 'access arguments' => array('edit chado_pub content'), 'type ' => MENU_CALLBACK, ); $items['tripal_pub/properties/minus/%/%'] = array( 'page callback' => 'tripal_pub_property_delete', 'page arguments' => array(3, 4), 'access arguments' => array('edit chado_pub content'), 'type ' => MENU_CALLBACK, ); $items['admin/tripal/tripal_pub/citation'] = array( 'title' => ' Create Citations', 'description' => 'Create citations in Chado with Drupal', 'page callback' => 'drupal_get_form', 'page arguments' => array('tripal_pub_citation_form'), 'access arguments' => array('administer tripal pubs'), 'type' => MENU_NORMAL_ITEM, ); return $items; } /** * Implements hook_theme(): Register themeing functions for this module * * * @return * An array of themeing functions to register * */ function tripal_pub_theme() { $themes = array( // node templates 'tripal_pub_base' => array( 'arguments' => array('node' => NULL), ), 'tripal_pub_properties' => array( 'arguments' => array('node' => NULL) ), 'tripal_pub_authors' => array( 'arguments' => array('node' => NULL) ), 'tripal_pub_references' => array( 'arguments' => array('node' => NULL) ), 'tripal_pub_relationships' => array( 'arguments' => array('node' => NULL) ), 'tripal_pub_featuremaps' => array( 'arguments' => array('node' => NULL) ), 'tripal_pub_features' => array( 'arguments' => array('node' => NULL) ), 'tripal_pub_libraries' => array( 'arguments' => array('node' => NULL) ), 'tripal_pub_projects' => array( 'arguments' => array('node' => NULL) ), 'tripal_pub_stocks' => array( 'arguments' => array('node' => NULL) ), // instructions page for the pub module 'tripal_pub_admin' => array( 'template' => 'tripal_pub_admin', 'arguments' => array(NULL), 'path' => drupal_get_path('module', 'tripal_pub') . '/theme' ), // themed forms 'tripal_pub_importer_setup_form' => array( 'arguments' => array('form'), ), 'tripal_pub_search_form' => array( 'arguments' => array('form'), ), 'chado_pub_node_form' => array( 'arguments' => array('form'), ), ); return $themes; } /** * Implement hook_perm(). */ function tripal_pub_perm() { return array( 'access chado_pub content', 'create chado_pub content', 'delete chado_pub content', 'edit chado_pub content', 'administer tripal pubs', ); } /** * Implement hook_access(). * * This hook allows node modules to limit access to the node types they define. * * @param $op * The operation to be performed * * @param $node * The node on which the operation is to be performed, or, if it does not yet exist, the * type of node to be created * * @param $account * A user object representing the user for whom the operation is to be performed * * @return * If the permission for the specified operation is not set then return FALSE. If the * permission is set then return NULL as this allows other modules to disable * access. The only exception is when the $op == 'create'. We will always * return TRUE if the permission is set. * */ function chado_pub_access($op, $node, $account ) { if ($op == 'create') { if (!user_access('create chado_pub content', $account)) { return FALSE; } return TRUE; } if ($op == 'update') { if (!user_access('edit chado_pub content', $account)) { return FALSE; } } if ($op == 'delete') { if (!user_access('delete chado_pub content', $account)) { return FALSE; } } if ($op == 'view') { if (!user_access('access chado_pub content', $account)) { return FALSE; } } return NULL; } /** * Implementation of tripal_pub_insert(). * * This function inserts user entered information pertaining to the Publication instance into the * 'pubauthor', 'pubprop', 'chado_pub', 'pub' talble of the database. * * @parm $node * Then node which contains the information stored within the node-ID * * */ function chado_pub_insert($node) { // we need an array suitable for the tripal_pub_create_citation() function // to automatically generate a citation if a uniquename doesn't already exist $pub_arr = array(); // if a pub_id already exists for this node then it already exists in Chado and // we get here because we are syncing the node. Therefore, we can skip the insert // but we always want to set the URL path alias to be the Chado pub ID if ($node->pub_id) { $pub['pub_id'] = $node->pub_id; } else { $properties = array(); // stores all of the properties we need to add $cross_refs = array(); // stores any cross references for this publication // get the list of properties for easy lookup (without doing lots of database queries $properties_list = array(); $sql = " SELECT CVTS.cvterm_id, CVTS.name, CVTS.definition FROM {cvtermpath} CVTP INNER JOIN {cvterm} CVTS ON CVTP.subject_id = CVTS.cvterm_id INNER JOIN {cvterm} CVTO ON CVTP.object_id = CVTO.cvterm_id INNER JOIN {cv} ON CVTO.cv_id = CV.cv_id WHERE CV.name = 'tripal_pub' and CVTO.name = 'Publication Details' and NOT CVTS.is_obsolete = 1 ORDER BY CVTS.name ASC "; $prop_types = chado_query($sql); while ($prop = db_fetch_object($prop_types)) { $properties_list[$prop->cvterm_id] = $prop->name; // The 'Citation' term is special because it serves // both as a property and as the uniquename for the // pub and we want it stored in both the pub table and the pubprop table if ($prop->name == 'Citation') { $properties[$prop->name][0] = $node->uniquename; } } // get the properties that should be added. Properties are in one of two forms: // 1) prop_value-[type id]-[index] // 2) new_value-[type id]-[index] // 3) new_id, new_value foreach ($node as $name => $value) { if (preg_match('/^new_value-(\d+)-(\d+)/', $name, $matches)) { $type_id = $matches[1]; $index = $matches[2]; $name = $properties_list[$type_id]; $properties[$name][$index] = trim($value); } } if ($node->new_id and $node->new_value) { $type_id = $node->new_id; $index = count($properties[$name]); $name = $properties_list[$type_id]; $properties[$name][$index] = trim($node->new_value); } // iterate through all of the properties and remove those that really are // part of the pub table fields foreach ($properties as $name => $element) { $value = trim($element[0]); // populate our $pub_array for building a citation $pub_arr[$name] = $value; // remove properties that are stored in the pub table if ($name == "Volume") { $volume = $value; unset($properties[$name]); } elseif ($name == "Volume Title") { $volumetitle = $value; unset($properties[$name]); } elseif ($name == "Issue") { $issue = $value; unset($properties[$name]); } elseif ($name == "Pages") { $pages = $value; unset($properties[$name]); } elseif ($name == "Publisher") { $publisher = $value; unset($properties[$name]); } elseif ($name == "Journal Name" or $name == "Conference Name") { $node->series_name = $value; unset($properties[$name]); } elseif ($name == "Journal Country" or $name == "Published Location") { $pubplace = $value; unset($properties[$name]); } elseif ($name == "Publication Dbxref") { // we will add the cross-references to the pub_dbxref table // but we also want to keep the property in the pubprop table so don't unset it $cross_refs[] = $value; } } // generate a citation for this pub if one doesn't already exist if (!$node->uniquename and array_key_exists('Citation', $properties)) { $pub_type = tripal_cv_get_cvterm_by_id($node->type_id); $pub_arr['Title'] = $node->pubtitle; $pub_arr['Publication Type'][0] = $pub_type->name; $pub_arr['Year'] = $node->pyear; $node->uniquename = tripal_pub_create_citation($pub_arr); $properties['Citation'][0] = $node->uniquename; } // insert the pub record $values = array( 'title' => trim($node->pubtitle), 'series_name' => substr(trim($node->series_name), 0, 255), 'type_id' => trim($node->type_id), 'pyear' => trim($node->pyear), 'is_obsolete' => $node->is_obsolete ? 'true' : 'false', 'uniquename' => trim($node->uniquename), 'volumetitle' => $volumetitle, 'volume' => $volume, 'issue' => $issue, 'pages' => $pages, 'miniref' => substr($miniref, 0, 255), 'publisher' => substr($publisher, 0, 255), 'pubplace' => substr($pubplace, 0, 255), ); $pub = tripal_core_chado_insert('pub', $values); if (!$pub) { drupal_set_message("Error inserting publication", "error"); watchdog('tripal_pub', "Error inserting publication", array(), WATCHDOG_ERROR); return; } // now add in the properties foreach ($properties as $property => $elements) { foreach ($elements as $rank => $value) { $status = tripal_pub_insert_property($pub['pub_id'], $property, $value, FALSE); if (!$status) { drupal_set_message("Error cannot add property: $property", "error"); watchdog('tripal_pub', "Error cannot add property: %prop", array('%property' => $property), WATCHDOG_ERROR); } } } // add in any database cross-references foreach ($cross_refs as $index => $ref) { $pub_dbxref = tripal_pub_add_pub_dbxref($pub['pub_id'], trim($ref)); if (!$pub_dbxref) { drupal_set_message("Error cannot add publication cross reference: $ref", "error"); watchdog('tripal_pub', "Error cannot add publication cross reference: %ref", array('%ref' => $ref), WATCHDOG_ERROR); } } } // if ($node->pub_id) {} else if ($pub) { // make sure the entry for this feature doesn't already exist in the chado_pub table // if it doesn't exist then we want to add it. $pub_id = chado_get_id_for_node('pub', $node) ; if (!$pub_id) { // next add the item to the drupal table $sql = "INSERT INTO {chado_pub} (nid, vid, pub_id) ". "VALUES (%d, %d, %d)"; db_query($sql, $node->nid, $node->vid, $pub['pub_id']); } } else { drupal_set_message(t('Unable to add publication.', 'warning')); watchdog('tripal_pub', 'Insert publication: Unable to create pub where values: %values', array('%values' => print_r($values, TRUE)), WATCHDOG_WARNING); } } /* * * Implements hook_update * * The purpose of the function is to allow the module to take action when an edited node is being * updated. It updates any name changes to the database tables that werec reated upon registering a Publication. * As well, the database will be changed, so the user changed information will be saved to the database. * * @param $node * The node being updated * * @ingroup tripal_pub */ function chado_pub_update($node) { if ($node->revision) { // there is no way to handle revisions in Chado but leave // this here just to make not we've addressed it. } // we need an array suitable for the tripal_pub_create_citation() function // to automatically generate a citation if a uniquename doesn't already exist $pub_arr = array(); // get the publication ID for this publication $pub_id = chado_get_id_for_node('pub', $node) ; $properties = array(); // stores all of the properties we need to add $cross_refs = array(); // stores any cross references for this publication // get the list of properties for easy lookup (without doing lots of database queries $properties_list = array(); $sql = " SELECT DISTINCT CVTS.cvterm_id, CVTS.name, CVTS.definition FROM {cvtermpath} CVTP INNER JOIN {cvterm} CVTS ON CVTP.subject_id = CVTS.cvterm_id INNER JOIN {cvterm} CVTO ON CVTP.object_id = CVTO.cvterm_id INNER JOIN {cv} ON CVTO.cv_id = CV.cv_id WHERE CV.name = 'tripal_pub' and (CVTO.name = 'Publication Details' or CVTS.name = 'Publication Type') and NOT CVTS.is_obsolete = 1 ORDER BY CVTS.name ASC "; $prop_types = chado_query($sql); while ($prop = db_fetch_object($prop_types)) { $properties_list[$prop->cvterm_id] = $prop->name; // The 'Citation' term is special because it serves // both as a property and as the uniquename for the // pub and we want it stored in both the pub table and the pubprop table if ($prop->name == 'Citation') { $properties[$prop->name][0] = $node->uniquename; } } // get the properties that should be added. Properties are in one of three forms: // 1) prop_value-[type id]-[index] // 2) new_value-[type id]-[index] // 3) new_id, new_value // dpm($node); foreach ($node as $key => $value) { if (preg_match('/^prop_value-(\d+)-(\d+)/', $key, $matches)) { $type_id = $matches[1]; $index = $matches[2]; $name = $properties_list[$type_id]; $properties[$name][$index] = trim($value); } if (preg_match('/^new_value-(\d+)-(\d+)/', $key, $matches)) { $type_id = $matches[1]; $index = $matches[2]; $name = $properties_list[$type_id]; $properties[$name][$index] = trim($value); } } if ($node->new_id and $node->new_value) { $type_id = $node->new_id; $name = $properties_list[$type_id]; $index = count($properties[$name]); $properties[$name][$index] = trim($node->new_value); } // iterate through all of the properties and remove those that really are // part of the pub table fields foreach ($properties as $name => $element) { foreach ($element as $index => $value) { // populate our $pub_array for building a citation $pub_arr[$name] = $value; // remove properties that are stored in the pub table if ($name == "Volume") { $volume = $value; unset($properties[$name]); } elseif ($name == "Volume Title") { $volumetitle = $value; unset($properties[$name]); } elseif ($name == "Issue") { $issue = $value; unset($properties[$name]); } elseif ($name == "Pages") { $pages = $value; unset($properties[$name]); } elseif ($name == "Publisher") { $publisher = $value; unset($properties[$name]); } elseif ($name == "Journal Name" or $name == "Conference Name") { $node->series_name = $value; unset($properties[$name]); } elseif ($name == "Journal Country" or $name == "Published Location") { $pubplace = $value; unset($properties[$name]); } elseif ($name == "Publication Dbxref") { // we will add the cross-references to the pub_dbxref table // but we also want to keep the property in the pubprop table so don't unset it $cross_refs[] = $value; } } } // generate a citation for this pub if one doesn't already exist if (!$node->uniquename) { $pub_type = tripal_cv_get_cvterm_by_id($node->type_id); $pub_arr['Title'] = $node->pubtitle; $pub_arr['Publication Type'][0] = $pub_type->name; $pub_arr['Year'] = $node->pyear; $node->uniquename = tripal_pub_create_citation($pub_arr); $properties['Citation'][0] = $node->uniquename; } // update the pub record $match = array( 'pub_id' => $pub_id, ); $values = array( 'title' => trim($node->pubtitle), 'type_id' => trim($node->type_id), 'pyear' => trim($node->pyear), 'is_obsolete' => $node->is_obsolete ? 'true' : 'false', 'uniquename' => trim($node->uniquename), 'series_name' => trim($node->series_name), 'volumetitle' => $volumetitle, 'volume' => $volume, 'issue' => $issue, 'pages' => $pages, 'miniref' => $miniref, 'publisher' => $publisher, 'pubplace' => $pubplace, ); $status = tripal_core_chado_update('pub', $match, $values); if (!$status) { drupal_set_message("Error updating publication", "error"); watchdog('tripal_pub', "Error updating publication", array(), WATCHDOG_ERROR); return; } // now add in the properties by first removing any the publication // already has and adding the ones we have tripal_core_chado_delete('pubprop', array('pub_id' => $pub_id)); foreach ($properties as $property => $elements) { foreach ($elements as $rank => $value) { $status = tripal_pub_insert_property($pub_id, $property, $value, FALSE); if (!$status) { drupal_set_message("Error cannot add property: '$property'", "error"); watchdog('tripal_pub', "Error cannot add property: '%prop'", array('%prop' => $property), WATCHDOG_ERROR); } } } // add in any database cross-references after first removing tripal_core_chado_delete('pub_dbxref', array('pub_id' => $pub_id)); foreach ($cross_refs as $index => $ref) { $pub_dbxref = tripal_pub_add_pub_dbxref($pub_id, trim($ref)); if (!$pub_dbxref) { drupal_set_message("Error cannot add publication cross reference: $ref", "error"); watchdog('tripal_pub', "Error cannot add publication cross reference: %ref", array('%ref' => $ref), WATCHDOG_ERROR); } } } /** * Implementation of tripal_pub_load(). * * * @param $node * The node that is to be accessed from the database * * @return $node * The node with the information to be loaded into the database * */ function chado_pub_load($node) { // get the feature details from chado $pub_id = chado_get_id_for_node('pub', $node); $values = array('pub_id' => $pub_id); $pub = tripal_core_generate_chado_var('pub', $values); // expand the 'text' fields as those aren't included by default // and they really shouldn't be so large to cause problems if (is_array($pub) or is_object($pub)) { $pub = tripal_core_expand_chado_vars($pub, 'field', 'pub.title'); $pub = tripal_core_expand_chado_vars($pub, 'field', 'pub.volumetitle'); $pub = tripal_core_expand_chado_vars($pub, 'field', 'pub.uniquename'); } // set the URL path $path = "pub/$pub_id"; $additions = new stdClass(); $additions->pub = $pub; return $additions; } /** * Implementation of tripal_pub_delete(). * * This function takes a node and if the delete button has been chosen by the user, the publication * and it's details will be removed.Following,given the node-ID, the instance will be deleted from * the 'chado_pub' table. * * @parm $node * Then node which contains the information stored within the node-ID * */ function chado_pub_delete(&$node) { $pub_id = chado_get_id_for_node('pub', $node); // if we don't have a pub id for this node then this isn't a node of // type chado_pub or the entry in the chado_pub table was lost. if (!$pub_id) { return; } // Remove data from {chado_pub}, {node} and {node_revisions} tables of // drupal database $sql_del = "DELETE FROM {chado_pub} ". "WHERE nid = %d ". "AND vid = %d"; db_query($sql_del, $node->nid, $node->vid); $sql_del = "DELETE FROM {node_revisions} ". "WHERE nid = %d ". "AND vid = %d"; db_query($sql_del, $node->nid, $node->vid); $sql_del = "DELETE FROM {node} ". "WHERE nid = %d ". "AND vid = %d"; db_query($sql_del, $node->nid, $node->vid); // Remove data from pub and pubprop tables of chado database as well chado_query("DELETE FROM {pubprop} WHERE pub_id = %d", $pub_id); chado_query("DELETE FROM {pub} WHERE pub_id = %d", $pub_id); } /** * Because we are using AJAX with a node form we need to provide a callback * for the chado_pub node form. This callback is different from the * default 'chado_pub_form' callback */ /* function tripal_pub_forms($form_id, $args) { $forms = array(); if($form_id == 'chado_pub_node_form') { $forms[$form_id] = array( 'callback' => 'chado_pub_node_form', 'callback arguments' => array($args) ); } return $forms; }*/ /* * */ function tripal_pub_form_alter(&$form, &$form_state, $form_id) { if ($form_id == "tripal_pub_importer_setup_form") { // updating the form through the ahah callback sets the action of // the form to the ahah callback URL. We need to set it back // to the normal form URL if ($form_state['values']['action'] == 'edit') { $form['#action'] = url("admin/tripal/tripal_pub/import/edit/" . $form_state['values']['pub_import_id']); } if ($form_state['values']['action'] == 'new') { $form['#action'] = url("admin/tripal/tripal_pub/import/new"); } } if ($form_id == "tripal_pub_search_form") { $form['#action'] = url("find/publications"); } if ($form_id == "chado_pub_node_form") { } } /** * * * @ingroup tripal_pub */ function tripal_pub_preprocess_tripal_pub_relationships(&$variables) { // we want to provide a new variable that contains the matched pubs. $pub = $variables['node']->pub; // normally we would use tripal_core_expand_chado_vars to expand our // organism object and add in the relationships, however whan a large // number of relationships are present this significantly slows the // query, therefore we will manually perform the query $sql = " SELECT P.title, P.pub_id, CP.nid, CVT.name as rel_type FROM {pub_relationship} PR INNER JOIN {pub} P ON PR.object_id = P.pub_id INNER JOIN {cvterm} CVT ON PR.type_id = CVT.cvterm_id LEFT JOIN public.chado_pub CP ON P.pub_id = CP.pub_id WHERE PR.subject_id = %d "; $as_subject = chado_query($sql, $pub->pub_id); $sql = " SELECT P.title, P.pub_id, CP.nid, CVT.name as rel_type FROM {pub_relationship} PR INNER JOIN {pub} P ON PR.subject_id = P.pub_id INNER JOIN {cvterm} CVT ON PR.type_id = CVT.cvterm_id LEFT JOIN public.chado_pub CP ON P.pub_id = CP.pub_id WHERE PR.object_id = %d "; $as_object = chado_query($sql, $pub->pub_id); // combine both object and subject relationshisp into a single array $relationships = array(); $relationships['object'] = array(); $relationships['subject'] = array(); // iterate through the object relationships while ($relationship = db_fetch_object($as_object)) { // get the relationship and child types $rel_type = t(preg_replace('/_/', " ", $relationship->rel_type)); $sub_type = t(preg_replace('/_/', " ", $relationship->sub_type)); if (!array_key_exists($rel_type, $relationships['object'])) { $relationships['object'][$rel_type] = array(); } if (!array_key_exists($sub_type, $relationships['object'][$rel_type])) { $relationships['object'][$rel_type][$sub_type] = array(); } $relationships['object'][$rel_type][$sub_type][] = $relationship; } // now add in the subject relationships while ($relationship = db_fetch_object($as_subject)) { // get the relationship and child types $rel_type = t(preg_replace('/_/', " ", $relationship->rel_type)); $obj_type = t(preg_replace('/_/', " ", $relationship->obj_type)); if (!array_key_exists($rel_type, $relationships['subject'])) { $relationships['subject'][$rel_type] = array(); } if (!array_key_exists($obj_type, $relationships['subject'][$rel_type])) { $relationships['subject'][$rel_type][$obj_type] = array(); } $relationships['subject'][$rel_type][$obj_type][] = $relationship; } $pub->all_relationships = $relationships; } /** * */ function tripal_pub_mail($key, &$message, $params) { $language = $message['language']; $variables = user_mail_tokens($params['account'], $language); switch($key) { case 'import_report': $headers = array( 'MIME-Version' => '1.0', 'Content-Type' => 'text/html; charset=UTF-8; format=flowed', 'Content-Transfer-Encoding' => '8Bit', 'X-Mailer' => 'Drupal' ); foreach ($headers as $key => $value) { $message['headers'][$key] = $value; } $message['subject'] = t('Publication import from !site', $variables, $language->language); $message['body'][] = $params['message']; break; } } /* * */ function tripal_pub_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { // we want the publications to always have a URL of http://[base url]/pub/[pub id] // where [pub id] is the Chado publication ID. This will allow for easy linking // into the publication without needing to know the node. Of course if you know the // node that will still work too (e.g. http://[base url]/node/[node id] // so the nodeapi function ensures that the URL path is set after insert or update // of the node and when the node is loaded if it hasn't yet been set. if ($node->type == 'chado_pub') { switch ($op) { case 'presave': break; case 'insert': $pub_id = chado_get_id_for_node('pub', $node); tripal_pub_set_pub_url($node, $pub_id); break; case 'load': if (!$node->path) { $pub_id = chado_get_id_for_node('pub', $node); $path = tripal_pub_set_pub_url($node, $pub_id); } break; case 'update': $pub_id = chado_get_id_for_node('pub', $node); tripal_pub_set_pub_url($node, $pub_id); break; case 'view': break; } } }