function location_user_migrate_delete_location_user in Migrate Extras 6
File
- ./
location_user.migrate.inc, line 55 - Integrates location_user module (part of location) with the migrate module
Code
function location_user_migrate_delete_location_user($lid) {
/* BIG problems, and some hacky solutions: see similar function in
* location.migrate.inc for details on assuptions being made here.
* This does the same things but for uid instead of nid.
*/
$result = db_query('SELECT nid, uid, genid FROM {location_instance} WHERE lid = %d AND uid <> 0 ORDER BY uid DESC', $lid);
if ($location_instance = db_fetch_array($result)) {
//at least one node matches this location
db_query('DELETE FROM {location_instance} WHERE lid = %d and uid = %d', array(
$lid,
$location_instance['uid'],
));
}
//check to see if ths is the last instance, and if it is, remove the location.
$count = db_result(db_query('SELECT COUNT(*) FROM {location_instance} WHERE lid = %d', $lid));
if ($count !== FALSE && $count == 0) {
$location = array(
'lid' => $lid,
);
location_invoke_locationapi($location, 'delete');
db_query('DELETE FROM {location} WHERE lid = %d', $location['lid']);
}
}