|
@@ -115,7 +115,7 @@ function flag_lists_add_js($type = NULL) {
|
|
$query->fields('f')
|
|
$query->fields('f')
|
|
->fields('fl')
|
|
->fields('fl')
|
|
->condition('fl.type', $type);
|
|
->condition('fl.type', $type);
|
|
-
|
|
|
|
|
|
+
|
|
$row = $query->execute()
|
|
$row = $query->execute()
|
|
->fetchObject();
|
|
->fetchObject();
|
|
|
|
|
|
@@ -176,7 +176,7 @@ function flag_lists_form($form, $form_state, $name = NULL, $type = NULL) {
|
|
$title_string_name = variable_get('flag_lists_name', 'list');
|
|
$title_string_name = variable_get('flag_lists_name', 'list');
|
|
$title_string = t('Edit your "@title" @name title', array('@title' => $flag->get_title(), '@name' => $title_string_name));
|
|
$title_string = t('Edit your "@title" @name title', array('@title' => $flag->get_title(), '@name' => $title_string_name));
|
|
drupal_set_title();
|
|
drupal_set_title();
|
|
-
|
|
|
|
|
|
+
|
|
$form['edit'] = array(
|
|
$form['edit'] = array(
|
|
'#type' => 'hidden',
|
|
'#type' => 'hidden',
|
|
'#value' => TRUE,
|
|
'#value' => TRUE,
|
|
@@ -248,7 +248,7 @@ function flag_lists_form_submit($form, $form_state, $account = NULL) {
|
|
$query->fields('f')
|
|
$query->fields('f')
|
|
->fields('fl')
|
|
->fields('fl')
|
|
->condition('fl.type', $type);
|
|
->condition('fl.type', $type);
|
|
-
|
|
|
|
|
|
+
|
|
$row = $query->execute()
|
|
$row = $query->execute()
|
|
->fetchObject();
|
|
->fetchObject();
|
|
|
|
|
|
@@ -597,3 +597,44 @@ function flag_lists_generate_lists_form_submit($form, &$form_state) {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Clean lists from deleted enties
|
|
|
|
+ */
|
|
|
|
+function flag_list_clean_deleted(){
|
|
|
|
+
|
|
|
|
+ drupal_set_title(t('Flag lists Clean'));
|
|
|
|
+ $output = '<p>' . t('This page shows all the deleted entityties id from flag lists.') . '</p>';
|
|
|
|
+
|
|
|
|
+ $total = 0;
|
|
|
|
+ $list = "<ul>";
|
|
|
|
+
|
|
|
|
+ $query = db_select('flag_lists_content');
|
|
|
|
+ $query->fields('flag_lists_content', array('entity_id', 'entity_type'));
|
|
|
|
+ $query->distinct();
|
|
|
|
+ $items = $query->execute()->fetchAll();
|
|
|
|
+
|
|
|
|
+ if ($items) {
|
|
|
|
+ foreach ($items as $key => $value) {
|
|
|
|
+ $entity = entity_load($value->entity_type, array($value->entity_id), array(), true);
|
|
|
|
+ // dsm($entity);
|
|
|
|
+ // break;
|
|
|
|
+ if(!isset($entity[$value->entity_id])){
|
|
|
|
+ $list .= "<li>".$value->entity_type ." <em>". $value->entity_id."</em> have been deleted does not exists anymore.</li>";
|
|
|
|
+ $total++;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // db_delete('flag_lists_content')
|
|
|
|
+ // ->condition('entity_type', $value->entity_type)
|
|
|
|
+ // ->condition('entity_id', $value->entity_id)
|
|
|
|
+ // ->execute();
|
|
|
|
+ // watchdog('flag_lists', t('Deleted entry @fcid from flat_lists_content', array('@fcid' => $value->fcid)));
|
|
|
|
+ // }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $list .= "</ul>";
|
|
|
|
+ $output .= "<p><strong>".$total ."</strong> entities have been deleted.</p>";
|
|
|
|
+ $output .= $list;
|
|
|
|
+ return $output;
|
|
|
|
+}
|