function chado_update_node_form_properties
2.x tripal_core.chado_nodes.properties.api.inc | chado_update_node_form_properties($node, $details, $retrieved_properties = FALSE) |
3.x tripal_core.chado_nodes.properties.api.inc | chado_update_node_form_properties($node, $details, $retrieved_properties = FALSE) |
This function is used in hook_insert or hook_update and handles inserting of any new properties
Parameters
$node: The node passed into hook_insert & hook_update
$details:
- property_table: the name of the _property linking table (ie: feature_property)
- base_table: the name of the base table (ie: feature)
- foreignkey_name: the name of the foreign key used to link to the node content (ie: feature_id)
- foreignkey_value: the value of the foreign key (ie: 445, if there exists a feature where feature_id=445)
$retrieved_properties: An array of properties from chado_retrieve_node_form_properties($node). This can be used if you need special handling for some of the properties (See FeatureMap chado_featuremap_insert for an example)
Related topics
21 calls to chado_update_node_form_properties()
- chado_analysis_insert in tripal_analysis/
includes/ tripal_analysis.chado_node.inc - Implements hook_insert(). When a new chado_analysis node is created we also need to add information to our chado_analysis table. This function is called on insert of a new node of type 'chado_analysis' and inserts the necessary information.
- chado_analysis_update in tripal_analysis/
includes/ tripal_analysis.chado_node.inc - Implements hook_update(). Update analyses
- chado_contact_insert in tripal_contact/
includes/ tripal_contact.chado_node.inc - Implements of hook_insert().
- chado_contact_update in tripal_contact/
includes/ tripal_contact.chado_node.inc - Implements hook_update
- chado_example_insert in tripal_example/
includes/ tripal_example.chado_node.inc - Implementation of hook_insert(). This function is called after the node is inserted into the database. We need it so that we can insert appropriate fields as provided by the user into the database. And so that we can link the new Drupal node to the…
1 string reference to 'chado_update_node_form_properties'
- chado_node_properties_form_update_properties in tripal_core/
api/ tripal_core.DEPRECATED.api.inc
File
- tripal_core/
api/ tripal_core.chado_nodes.properties.api.inc, line 882 - API to manage the chado prop table for various Tripal Node Types
Code
function chado_update_node_form_properties($node, $details, $retrieved_properties = FALSE) {
$details['foreignkey_value'] = (isset($details['foreignkey_value'])) ? $details['foreignkey_value'] : 0;
if (isset($node->property_table) AND ($details['foreignkey_value'] > 0)) {
// First remove existing property links
chado_delete_record($details['property_table'], array($details['foreignkey_name'] => $details['foreignkey_value']));
// Add back in property links and insert properties as needed
if ($retrieved_properties) {
$properties = $retrieved_properties;
}
else {
$properties = chado_retrieve_node_form_properties($node);
}
foreach ($properties as $type_id => $ranks) {
foreach ($ranks as $rank => $value) {
if (preg_match('/^TEMP/', $rank)) {
$rank = chado_get_table_max_rank(
$details['property_table'],
array(
$details['foreignkey_name'] => $details['foreignkey_value'],
'type_id' => $type_id
)
);
$rank = strval($rank + 1);
}
$success = chado_insert_record(
$details['property_table'],
array(
$details['foreignkey_name'] => $details['foreignkey_value'],
'type_id' => $type_id,
'value' => $value,
'rank' => $rank
)
);
if (!$success) {
tripal_report_error('tripal_' . $details['base_table'], TRIPAL_ERROR,
$details['base_table'] . ' Insert: Unable to insert property type_id %cvterm with value %value.',
array('%cvterm' => $type_id, '%value' => $value));
}
}
}
}
}