You are here

function getlocations_fields_delete_revision_record in Get Locations 7

Same name and namespace in other branches
  1. 7.2 modules/getlocations_fields/getlocations_fields.module \getlocations_fields_delete_revision_record()

Create a location

Parameters

array $location: The location

array $relations: Relationship information

1 call to getlocations_fields_delete_revision_record()
getlocations_fields_save_locations in modules/getlocations_fields/getlocations_fields.module

File

modules/getlocations_fields/getlocations_fields.module, line 2338
getlocations_fields.module @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Code

function getlocations_fields_delete_revision_record($location, $relations) {
  if (isset($location['glid']) && $location['glid']) {
    $glid = $location['glid'];
    getlocations_fields_delete_revision_record_relations($relations, $glid);

    // now see if there are any left for glid
    $query = db_select('getlocations_fields', 'f');
    $query
      ->fields('e', array(
      'nid',
      'vid',
      'uid',
      'tid',
      'cid',
    ));
    $query
      ->join('getlocations_fields_entities', 'e', 'f.glid=e.glid');
    $query
      ->condition('e.glid', $glid);
    $rows = $query
      ->execute();
    $ct = 0;
    foreach ($rows as $row) {
      if ($row->nid || $row->vid || $row->uid || $row->tid || $row->cid) {
        $ct++;
      }
    }
    if (!$ct) {
      db_delete('getlocations_fields')
        ->condition('glid', $glid)
        ->execute();
    }
  }
}