123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- <?php
- function tripal_bulk_loader_is_record_name_unique($new_record_name, $template_id, $template_array = NULL, $current_priority = NULL) {
-
- if (empty($template_array)) {
- $template = db_fetch_object(db_query("SELECT * FROM {tripal_bulk_loader_template} WHERE template_id=%d", $template_id));
- $template_array = unserialize($template->template_array);
- if (!is_array($template_array)) {
- watchdog(
- 'tripal_bulk_loader',
- 'Unable to retrieve template array from database where template_id=%template_id',
- array('%template_id' => $template_id),
- WATCHDOG_WARNING
- );
- return FALSE;
- }
- }
-
- if (empty($new_record_name)) {
- return FALSE;
- }
-
- foreach ($template_array as $priority => $t) {
- if (strcmp($t['record_id'], $new_record_name) == 0) {
- if (($priority != $current_priority) AND ($current_priority !== NULL)) {
- return FALSE;
- }
- }
- }
- return TRUE;
- }
- function tripal_bulk_loader_delete_record($delete_priority, $template_array) {
- if (empty($template_array)) {
- drupal_set_message("Unable to delete record with a priority of $priority since the template was not supplied",'error');
- return FALSE;
- }
- $new_template_array = array();
- $i=0;
- foreach ($template_array as $priority => $record) {
- if ($priority != $delete_priority) {
- $new_template_array[$i] = $record;
- $i++;
- }
- }
- return $new_template_array;
- }
- function tripal_bulk_loader_delete_field($priority, $delete_field_index, $template_array) {
- if (empty($template_array)) {
- drupal_set_message("Unable to delete record with a priority of $priority since the template was not supplied",'error');
- return FALSE;
- }
-
-
- $new_template_array = $template_array;
- $new_template_array[$priority]['fields'] = array();
- $i=0;
- foreach ($template_array[$priority]['fields'] as $field_index => $field_details) {
- if ($field_index != $delete_field_index) {
- $new_template_array[$priority]['fields'][$i] = $field_details;
- $i++;
- }
- }
-
- if (empty($new_template_array[$priority]['fields'])) {
- $new_template_array = tripal_bulk_loader_delete_record($priority, $new_template_array);
- }
- return $new_template_array;
- }
|