patched flag list to trigger remove entity from lists when this entity is deleted
This commit is contained in:
parent
e004b7a238
commit
f0cb6175c1
@ -0,0 +1,55 @@
|
||||
diff --git a/flag_lists.module b/flag_lists.module
|
||||
index d829113..b3c04f0 100644
|
||||
--- a/flag_lists.module
|
||||
+++ b/flag_lists.module
|
||||
@@ -1587,6 +1587,32 @@ function flag_lists_fix_link(&$link, $action) {
|
||||
return $fcid;
|
||||
}
|
||||
|
||||
+
|
||||
+ /**
|
||||
+ * Remove all entries of entity_id and type
|
||||
+ *
|
||||
+ * @param $entity_id
|
||||
+ * Entity id which has been flagged.
|
||||
+ * @param $type
|
||||
+ * The entity type.
|
||||
+ */
|
||||
+ function _flag_lists_remove_entity($entity_id, $type) {
|
||||
+ $query = db_select('flag_lists_content')
|
||||
+ ->condition('entity_id', $entity_id)
|
||||
+ ->condition('entity_type', $type);
|
||||
+ $query->fields('flag_lists_content', array('fcid', 'fid', 'uid', 'sid'));
|
||||
+ $items = $query->execute()->fetchAll();
|
||||
+
|
||||
+ if ($items) {
|
||||
+ foreach ($items as $key => $value) {
|
||||
+ db_delete('flag_lists_content')
|
||||
+ ->condition('fcid', $value->fcid)
|
||||
+ ->execute();
|
||||
+ watchdog('flag_lists', t('Deleted entry @fcid from flat_lists_content', array('@fcid' => $value->fcid)));
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
/**
|
||||
* Updates the flag count for this content
|
||||
*/
|
||||
@@ -1766,3 +1792,17 @@ function flag_lists_views_form_substitutions() {
|
||||
$select_all_placeholder => drupal_render($select_all),
|
||||
);
|
||||
}
|
||||
+
|
||||
+
|
||||
+/**
|
||||
+ * Implements hook_entity_delete
|
||||
+ */
|
||||
+function flag_lists_entity_delete($entity, $type) {
|
||||
+ foreach (flag_get_flags($type) as $flag) {
|
||||
+ if (isset($entity->vid)) {
|
||||
+ $items = _flag_lists_remove_entity($entity->vid, $type);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+
|
@ -1575,6 +1575,32 @@ function flag_lists_fix_link(&$link, $action) {
|
||||
return $fcid;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove all entries of entity_id and type
|
||||
*
|
||||
* @param $entity_id
|
||||
* Entity id which has been flagged.
|
||||
* @param $type
|
||||
* The entity type.
|
||||
*/
|
||||
function _flag_lists_remove_entity($entity_id, $type) {
|
||||
$query = db_select('flag_lists_content')
|
||||
->condition('entity_id', $entity_id)
|
||||
->condition('entity_type', $type);
|
||||
$query->fields('flag_lists_content', array('fcid', 'fid', 'uid', 'sid'));
|
||||
$items = $query->execute()->fetchAll();
|
||||
|
||||
if ($items) {
|
||||
foreach ($items as $key => $value) {
|
||||
db_delete('flag_lists_content')
|
||||
->condition('fcid', $value->fcid)
|
||||
->execute();
|
||||
watchdog('flag_lists', t('Deleted entry @fcid from flat_lists_content', array('@fcid' => $value->fcid)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the flag count for this content
|
||||
*/
|
||||
@ -1735,3 +1761,17 @@ function flag_lists_views_form_substitutions() {
|
||||
$select_all_placeholder => drupal_render($select_all),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_entity_delete
|
||||
*/
|
||||
function flag_lists_entity_delete($entity, $type) {
|
||||
foreach (flag_get_flags($type) as $flag) {
|
||||
if (isset($entity->vid)) {
|
||||
$items = _flag_lists_remove_entity($entity->vid, $type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
1737
sites/all/modules/contrib/flag/flag_lists/flag_lists.module.orig
Normal file
1737
sites/all/modules/contrib/flag/flag_lists/flag_lists.module.orig
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user