diff --git a/PATCH_LIST.txt b/PATCH_LIST.txt
index 17696785..40ea7a6d 100644
--- a/PATCH_LIST.txt
+++ b/PATCH_LIST.txt
@@ -33,3 +33,5 @@ login_tobogan (pd with field permission et donc field collection)
- https://www.drupal.org/node/1365764#comment-10286257
- logintoboggan-exempting_lt_preauth_role_from_user_permissions_js-1365764-52.patch
- interdiff-1365764-23-52-do-not-test.diff
+flag_lists
+ - https://www.drupal.org/project/flag_lists/issues/2114731
diff --git a/flag_lists-remove_deleted_entity-2114731-2.patch b/flag_lists-remove_deleted_entity-2114731-2.patch
new file mode 100644
index 00000000..27f6f074
--- /dev/null
+++ b/flag_lists-remove_deleted_entity-2114731-2.patch
@@ -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);
++ }
++ }
++}
++
++
diff --git a/sites/all/modules/contrib/flag/flag_lists/flag_lists.info b/sites/all/modules/contrib/flag/flag_lists/flag_lists.info
index 47f2d80e..660f484b 100644
--- a/sites/all/modules/contrib/flag/flag_lists/flag_lists.info
+++ b/sites/all/modules/contrib/flag/flag_lists/flag_lists.info
@@ -23,9 +23,9 @@ files[] = includes/flag_lists_handler_filter_list.inc
description = Allows users to create personal flag lists.
-; Information added by Drupal.org packaging script on 2016-09-07
-version = "7.x-3.1"
+; Information added by Drupal.org packaging script on 2017-10-02
+version = "7.x-3.2"
core = "7.x"
project = "flag_lists"
-datestamp = "1473230043"
+datestamp = "1506952771"
diff --git a/sites/all/modules/contrib/flag/flag_lists/flag_lists.install b/sites/all/modules/contrib/flag/flag_lists/flag_lists.install
index e9436c5a..3d6a834a 100644
--- a/sites/all/modules/contrib/flag/flag_lists/flag_lists.install
+++ b/sites/all/modules/contrib/flag/flag_lists/flag_lists.install
@@ -160,7 +160,7 @@ function flag_lists_schema() {
'type' => array(
'type' => 'varchar',
'length' => '32',
- 'not null' => FALSE,
+ 'not null' => TRUE,
'default' => '')
),
'primary key' => array('name', 'type'),
@@ -204,22 +204,22 @@ function flag_lists_uninstall() {
db_delete('variable')->condition('name', 'flag_lists%', 'LIKE')->execute();
$view_to_delete = views_get_view('flag_lists');
- if (!empty($view_to_delete)) {
+ if (!empty($view_to_delete)) {
views_delete_view($view_to_delete);
}
$view_to_delete =views_get_view('flag_lists_content');
- if (!empty($view_to_delete)) {
+ if (!empty($view_to_delete)) {
views_delete_view($view_to_delete);
}
$view_to_delete = views_get_view('flag_lists_user_lists');
- if (!empty($view_to_delete)) {
+ if (!empty($view_to_delete)) {
views_delete_view($view_to_delete);
}
$view_to_delete = views_get_view('flag_lists_user_list');
- if (!empty($view_to_delete)) {
+ if (!empty($view_to_delete)) {
views_delete_view($view_to_delete);
}
@@ -230,32 +230,32 @@ function flag_lists_uninstall() {
* Get rid of garbage list entries that are orphaned from a list
*/
function flag_lists_update_7000() {
- // $orphans = db_query("SELECT flc.fcid, flc.fid, flc.content_id, flc.uid, flcounts.content_type, count
- // FROM {flag_lists_content} flc
- // JOIN {flag_lists_counts} flcounts ON flcounts.fid=flc.fid AND flc.content_id=flcounts.content_id
- // LEFT JOIN {flag_lists_flags} flf ON flf.fid=flc.fid
- // WHERE flf.fid IS NULL");
- //
- // foreach ($orphans as $orphan) {
- // $num_deleted = db_delete('flag_lists_content')
- // ->condition('fid', $orphan->fid)
- // ->condition('fcid', $orphan->fcid)
- // ->condition('uid', $orphan->uid)
- // ->execute();
- //
- // if (!empty($num_deleted)) {
- // drupal_set_message("Deleting flag_id: $orphan->fid flag_content_id: $orphan->fcid");
- //
- // db_update('flag_lists_counts')
- // ->fields(array(
- // 'count' => ($orphan->count <= 1) ? 0 : $orphan->count - 1,
- // ))
- // ->condition('content_type', $orphan->content_type)
- // ->condition('fid', $orphan->fid)
- // ->condition('content_id', $orphan->content_id)
- // ->execute();
- // }
- // }
+ $orphans = db_query("SELECT flc.fcid, flc.fid, flc.content_id, flc.uid, flcounts.content_type, count
+ FROM {flag_lists_content} flc
+ JOIN {flag_lists_counts} flcounts ON flcounts.fid=flc.fid AND flc.content_id=flcounts.content_id
+ LEFT JOIN {flag_lists_flags} flf ON flf.fid=flc.fid
+ WHERE flf.fid IS NULL");
+
+ foreach ($orphans as $orphan) {
+ $num_deleted = db_delete('flag_lists_content')
+ ->condition('fid', $orphan->fid)
+ ->condition('fcid', $orphan->fcid)
+ ->condition('uid', $orphan->uid)
+ ->execute();
+
+ if (!empty($num_deleted)) {
+ drupal_set_message("Deleting flag_id: $orphan->fid flag_content_id: $orphan->fcid");
+
+ db_update('flag_lists_counts')
+ ->fields(array(
+ 'count' => ($orphan->count <= 1) ? 0 : $orphan->count - 1,
+ ))
+ ->condition('content_type', $orphan->content_type)
+ ->condition('fid', $orphan->fid)
+ ->condition('content_id', $orphan->content_id)
+ ->execute();
+ }
+ }
}
@@ -263,48 +263,48 @@ function flag_lists_update_7000() {
* Update the flag_lists_flags table
*/
function flag_lists_update_7301() {
- // db_change_field('flag_lists_flags','content_type', 'entity_type',
- // array(
- // 'type' => 'varchar',
- // 'length' => '32',
- // 'not null' => TRUE,
- // 'default' => '',
- // ));
+ db_change_field('flag_lists_flags','content_type', 'entity_type',
+ array(
+ 'type' => 'varchar',
+ 'length' => '32',
+ 'not null' => TRUE,
+ 'default' => '',
+ ));
}
/**
* Update the flag_lists_content table
*/
function flag_lists_update_7302() {
- // db_drop_unique_key('flag_lists_content','fid_content_id_uid_sid');
- // db_drop_index('flag_lists_content','content_type_content_id');
- // db_drop_index('flag_lists_content','content_type_uid_sid');
- //
- // db_change_field('flag_lists_content','content_type', 'entity_type',
- // array(
- // 'type' => 'varchar',
- // 'length' => '32',
- // 'not null' => TRUE,
- // 'default' => '',
- // ));
- //
- // db_change_field('flag_lists_content','content_id', 'entity_id',
- // array(
- // 'type' => 'int',
- // 'unsigned' => TRUE,
- // 'not null' => TRUE,
- // 'default' => 0,
- // ));
- //
- // db_add_unique_key('flag_lists_content',
- // 'fid_entity_id_uid_sid',
- // array('fid', 'entity_id', 'uid', 'sid'));
- // db_add_index('flag_lists_content',
- // 'entity_type_uid_sid',
- // array('entity_type', 'uid', 'sid'));
- // db_add_index('flag_lists_content',
- // 'entity_type_entity_id',
- // array('entity_type', 'entity_id'));
+ db_drop_unique_key('flag_lists_content','fid_content_id_uid_sid');
+ db_drop_index('flag_lists_content','content_type_content_id');
+ db_drop_index('flag_lists_content','content_type_uid_sid');
+
+ db_change_field('flag_lists_content','content_type', 'entity_type',
+ array(
+ 'type' => 'varchar',
+ 'length' => '32',
+ 'not null' => TRUE,
+ 'default' => '',
+ ));
+
+ db_change_field('flag_lists_content','content_id', 'entity_id',
+ array(
+ 'type' => 'int',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ 'default' => 0,
+ ));
+
+ db_add_unique_key('flag_lists_content',
+ 'fid_entity_id_uid_sid',
+ array('fid', 'entity_id', 'uid', 'sid'));
+ db_add_index('flag_lists_content',
+ 'entity_type_uid_sid',
+ array('entity_type', 'uid', 'sid'));
+ db_add_index('flag_lists_content',
+ 'entity_type_entity_id',
+ array('entity_type', 'entity_id'));
}
/**
@@ -315,29 +315,29 @@ function flag_lists_update_7303() {
db_drop_index('flag_lists_counts','fid_content_type');
db_drop_index('flag_lists_counts','content_type_content_id');
- // db_change_field('flag_lists_counts','content_type', 'entity_type',
- // array(
- // 'type' => 'varchar',
- // 'length' => '32',
- // 'not null' => TRUE,
- // 'default' => '',
- // ));
- // db_change_field('flag_lists_counts','content_id', 'entity_id',
- // array(
- // 'type' => 'int',
- // 'unsigned' => TRUE,
- // 'not null' => TRUE,
- // 'default' => 0,
- // 'disp-width' => '10',
- // ),
- // array('primary key' => array('fid', 'entity_id')));
+ db_change_field('flag_lists_counts','content_type', 'entity_type',
+ array(
+ 'type' => 'varchar',
+ 'length' => '32',
+ 'not null' => TRUE,
+ 'default' => '',
+ ));
+ db_change_field('flag_lists_counts','content_id', 'entity_id',
+ array(
+ 'type' => 'int',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ 'default' => 0,
+ 'disp-width' => '10',
+ ),
+ array('primary key' => array('fid', 'entity_id')));
- // db_add_index('flag_lists_counts',
- // 'fid_entity_type',
- // array('fid', 'entity_type'));
- // db_add_index('flag_lists_counts',
- // 'entity_type_entity_id',
- // array('entity_type', 'entity_id'));
+ db_add_index('flag_lists_counts',
+ 'fid_entity_type',
+ array('fid', 'entity_type'));
+ db_add_index('flag_lists_counts',
+ 'entity_type_entity_id',
+ array('entity_type', 'entity_id'));
}
/**
@@ -385,3 +385,16 @@ function flag_lists_update_7305() {
'not null' => TRUE,
));
}
+
+/**
+ * Update the flag_lists_types table
+ */
+function flag_lists_update_7306() {
+ db_change_field('flag_lists_types','type', 'type',
+ array(
+ 'type' => 'varchar',
+ 'length' => '32',
+ 'not null' => TRUE,
+ 'default' => '',
+ ));
+}
diff --git a/sites/all/modules/contrib/flag/flag_lists/flag_lists.module b/sites/all/modules/contrib/flag/flag_lists/flag_lists.module
index 04b4ff12..0ba6bcb8 100644
--- a/sites/all/modules/contrib/flag/flag_lists/flag_lists.module
+++ b/sites/all/modules/contrib/flag/flag_lists/flag_lists.module
@@ -141,7 +141,7 @@ function flag_lists_menu() {
'type' => MENU_LOCAL_TASK,
);
$items['user/%user/flag/lists/%'] = array(
- 'title' =>drupal_ucfirst(variable_get('flag_lists_name', 'list')
+ 'title' =>drupal_ucfirst(variable_get('flag_lists_name', 'list')
. ' ' . 'content'),
'page callback' => 'flag_lists_user_list',
'page arguments' => array(1, 4),
@@ -573,7 +573,7 @@ function flag_lists_ops_form_submit($form, &$form_state) {
foreach ($user_flag_lists as $key => $op) {
// Iterate over all flags by this user
list($k1,$k2,$owner,$ofid) = explode('_', $key);
-
+
foreach ($ops as $op) {
// Iterate over all selected items
list($nid,$fid) = array_merge( explode('-', $op), array(FALSE));
@@ -1009,7 +1009,7 @@ function flag_lists_get_user_flags($content_type = NULL, $account = NULL, $use_f
foreach ($flags as $key => $flag) {
if (!isset($flag->module)) {
// Assume flag is from flag module
- $flags[$key]->module = 'flag';
+ $flags[$key]->module = 'flag';
}
// Strip out any list templates
if (stristr($flag->name, 'fl_template') !== FALSE) {
@@ -1408,7 +1408,7 @@ function flag_lists_page($action = NULL, $flag_name = NULL, $entity_id = NULL) {
// Shorten up the variables that affect the behavior of this page.
$js = isset($_REQUEST['js']);
- $token = $_REQUEST['token'];
+ $token = isset($_REQUEST['token']) ? $_REQUEST['token'] : '';
// Specifically $_GET to avoid getting the $_COOKIE variable by the same key.
$has_js = isset($_GET['has_js']);
@@ -1444,7 +1444,7 @@ function flag_lists_page($action = NULL, $flag_name = NULL, $entity_id = NULL) {
else {
drupal_set_message($error);
drupal_access_denied();
- return;
+ exit;
}
}
@@ -1481,6 +1481,45 @@ function flag_lists_fix_link(&$link, $action) {
$link = str_replace('/flag/' . $action . '/', '/flag-lists/' . $action . '/', $link);
}
+
+/**
+ * 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)));
+ }
+ }
+}
+
+/**
+ * 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);
+ }
+ }
+}
+
+
+
/**
* Flags, or unflags, an item.
*
diff --git a/sites/all/modules/contrib/flag/flag_lists/includes/flag_lists_handler_filter_template.inc b/sites/all/modules/contrib/flag/flag_lists/includes/flag_lists_handler_filter_template.inc
index a39d829d..5cc88a78 100644
--- a/sites/all/modules/contrib/flag/flag_lists/includes/flag_lists_handler_filter_template.inc
+++ b/sites/all/modules/contrib/flag/flag_lists/includes/flag_lists_handler_filter_template.inc
@@ -7,11 +7,27 @@ class flag_lists_handler_filter_template extends views_handler_filter_in_operato
function get_value_options() {
if (!isset($this->value_options)) {
$this->value_title = t('List templates');
+ $this->value_options = array();
$templates = flag_lists_get_templates();
- foreach ($templates as $template) {
- $options[$template->name] = $template->name;
+ if (empty($templates)) {
+ drupal_set_message(
+ t('No templates found, create a flag lists template',
+ array('@url' => url('/admin/structure/flags/lists/template') )),
+ 'info');
+ }
+ else if ($templates['0'] === FALSE) {
+ drupal_set_message(
+ t('No enabled template found, enable the built in flag lists template',
+ array('@url' => url('/admin/structure/flags/manage/fl_template') )),
+ 'warning');
+ }
+ else {
+ foreach ($templates as $template) {
+ $options[$template->name] = $template->name;
+ }
+ $this->value_options = $options;
}
- $this->value_options = $options;
}
+ return $this->value_options;
}
}
diff --git a/sites/all/modules/gui/materiobasemod/materio_admin.module b/sites/all/modules/gui/materiobasemod/materio_admin.module
index fbe5ce67..a7781824 100644
--- a/sites/all/modules/gui/materiobasemod/materio_admin.module
+++ b/sites/all/modules/gui/materiobasemod/materio_admin.module
@@ -18,6 +18,10 @@ function materio_admin_permission() {
'title' => t('access duplicate mails list'),
'description' => t('access duplicate mails list.'),
),
+ 'access missing flags list' => array(
+ 'title' => t('access missing flags list'),
+ 'description' => t('access missing flags list.'),
+ ),
'materio admin fix term reference field' => array(
'title' => t('Materio admin fix term reference field'),
'description' => t('Materio admin fix term reference field.'),
@@ -55,6 +59,15 @@ function materio_admin_menu() {
}
}
+ if(module_exists('flag') && module_exists('flag_lists')){
+ $items['admin/people/missingflags'] = array(
+ 'title' => "Missing Flags",
+ 'page callback' => 'materio_missingflags',
+ 'access callback' => 'user_access',
+ 'access arguments' => array('access missing flags list'),
+ 'type' => MENU_LOCAL_TASK
+ );
+ }
// fix term ref field lost with taxonomy
$items['admin/config/content/materio'] = array(
@@ -114,6 +127,43 @@ function materio_duplicatemails(){
return $output;
}
+
+function materio_missingflags(){
+ $flags = db_query('SELECT fcid,fid,entity_type,entity_id,uid FROM {flag_lists_content}');
+
+ foreach ($flags as $key => $value) {
+ // $entity = entity_load($value->entity_type, array($value->entity_id));
+ $query = new EntityFieldQuery();
+ $query
+ ->entityCondition('entity_type', $value->entity_type)
+ ->propertyCondition('nid', $value->entity_id);
+ $entity = $query->execute();
+
+ if(!isset($entity['node'])){
+ $missingentities[$value->fid] = $value;
+ }
+ }
+
+ // Bail out early if there are no duplicates.
+ if (!$missingentities) {
+ return t('No missing entities in flags.');
+ }else{
+ dsm($missingentities);
+ }
+
+ // delete flags with missing entities
+ foreach ($missingentities as $fid => $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)));
+ }
+
+ // Turn the data we've got into markup.
+ $output = t('@count missing entities in flag lists have been cleaned', array('@count'=> count($missingentities)));
+ return $output;
+}
+
function materio_admin_fix_termref_fields_form(){
drupal_set_title('Fix term reference fields', PASS_THROUGH);