function user_relationship_implications_user_relationships_delete in User Relationships 7
Implements hook_user_relationships_delete().
File
- user_relationship_implications/
user_relationship_implications.module, line 169 - Drupal Module: User Relationship Implications
Code
function user_relationship_implications_user_relationships_delete($relationship, $action) {
$current_type = user_relationships_type_load($relationship->rtid);
// nothing else matters if there aren't implications involved
$reversed = array_filter($current_type->implies, '_user_relationship_implications_filter_for_reverse');
if (!$current_type->implied_by && !$reversed) {
return;
}
// load relationships that imply this relationship
$rtids = array_merge(array_keys($current_type->implied_by), array_keys($reversed));
$relationships = user_relationships_load(array(
'between' => array(
$relationship->requester_id,
$relationship->requestee_id,
),
'rtid' => $rtids,
), array(
'sort' => 'rtid',
));
foreach ($relationships as $rtid => $relationship) {
$relationship = array_shift($relationship);
// the relationship being deleted (current_type) is implied by this relationship (only matters if "strict" is set)
if (isset($current_type->implied_by[$rtid]) && $current_type->implied_by[$rtid]->strict || isset($reversed[$rtid]) && $reversed[$rtid]->strict) {
user_relationships_delete_relationship($relationship, $current_type->deleted_by, $action);
drupal_set_message(user_relationships_get_message('removed', $relationship));
}
}
}