Commit 77e59912 authored by yched's avatar yched

#126333 / #134812 : update CCK-dev to work with Views-dev (pre Views-1.6)

parent 9ffb85fa
...@@ -422,9 +422,6 @@ function content_update_1003() { ...@@ -422,9 +422,6 @@ function content_update_1003() {
} }
variable_set('content_schema_version', 1003); variable_set('content_schema_version', 1003);
// Set a followup flag for content_update_1005.
$_SESSION['content_update_1003_followup'] = TRUE;
return $ret; return $ret;
} }
...@@ -445,7 +442,7 @@ function content_update_1004() { ...@@ -445,7 +442,7 @@ function content_update_1004() {
} }
if ($fields) { if ($fields) {
$ret[] = update_sql("DELETE FROM {node_field} WHERE field_name NOT IN (". implode(', ', $fields) .")"); $ret[] = update_sql("DELETE FROM {node_field} WHERE field_name NOT IN (". implode(', ', $fields) .")");
} }
// drop 'content_type_' table // drop 'content_type_' table
$table = _content_tablename('', CONTENT_DB_STORAGE_PER_CONTENT_TYPE); $table = _content_tablename('', CONTENT_DB_STORAGE_PER_CONTENT_TYPE);
...@@ -470,26 +467,9 @@ function content_update_1004() { ...@@ -470,26 +467,9 @@ function content_update_1004() {
} }
/** /**
* Regenerate views (was in content_update_1003, but was later moved out in a separate update * Empty update - Was regenerating views after update_1003, but is not needed with Views 1.6
*/ */
function content_update_1005() { function content_update_1005() {
$ret = array();
if (isset($_SESSION['content_update_1003_followup'])) {
content_clear_type_cache();
if (module_exists('views')) {
include_once('./'. drupal_get_path('module', 'content') .'/content_views.inc');
$updated_views = _content_views_rebuild_views(array_keys(content_fields()));
foreach ($updated_views as $view) {
$ret[] = array(
'query' => strtr('The views %view has been regenerated.', array('%view' => $view)),
'success' => TRUE
);
}
}
}
return $ret;
} }
/** /**
......
...@@ -395,7 +395,7 @@ function content_admin_display_overview_form_submit($form_id, $form_values) { ...@@ -395,7 +395,7 @@ function content_admin_display_overview_form_submit($form_id, $form_values) {
} }
db_query("UPDATE {node_field_instance} SET display_settings = '%s' WHERE type_name = '%s' AND field_name = '%s'", db_query("UPDATE {node_field_instance} SET display_settings = '%s' WHERE type_name = '%s' AND field_name = '%s'",
serialize($display_settings), $form_values['type_name'], $fieldname); serialize($display_settings), $type, $fieldname);
} }
content_clear_type_cache(); content_clear_type_cache();
} }
...@@ -1012,13 +1012,6 @@ function _content_admin_field_submit($form_id, $form_values) { ...@@ -1012,13 +1012,6 @@ function _content_admin_field_submit($form_id, $form_values) {
} }
content_alter_db_field($prev_field, $prev_columns, $new_field, $new_columns); content_alter_db_field($prev_field, $prev_columns, $new_field, $new_columns);
// regenerate views queries if 'multiple' status was changed
if (module_exists('views')) {
if ($new_field['multiple'] != $prev_field['multiple']) {
_content_views_rebuild_views(array($new_field['field_name']));
}
}
return 'admin/content/types/'. $type['url_str'] .'/fields'; return 'admin/content/types/'. $type['url_str'] .'/fields';
} }
......
...@@ -272,55 +272,3 @@ function content_views_argument_handler($op, &$query, $argtype, $arg = '') { ...@@ -272,55 +272,3 @@ function content_views_argument_handler($op, &$query, $argtype, $arg = '') {
return content_format($field, $item); return content_format($field, $item);
} }
} }
/**
* Rebuild the cached queries for the views using a given field.
* Called when a field changes its 'multiple' status.
* Can also be useful for updates.
*
* @param unknown_type $update_fields
*/
function _content_views_rebuild_views($update_fields) {
$updated_views = array();
views_load_cache();
$tables = _views_get_tables(true);
$result = db_query("SELECT name FROM {view_view} ORDER BY name");
// TODO : do we have to do that for default views as well ?
while ($row = db_fetch_array($result)) {
// if a query has been stored for the view
if (!empty($row['name'])) {
$view = views_get_view($row['name']);
$view_content_fields = array();
foreach ($view->field as $field) {
$info = $tables['fields']['base'][$field['fullname']];
if (isset($info['content_field'])) {
$view_content_fields[] = $info['content_field']['field_name'];
}
}
foreach ($view->filter as $filter) {
$info = $tables['filters']['base'][$filter['field']];
if (isset($info['content_field'])) {
$view_content_fields[] = $info['content_field']['field_name'];
}
}
foreach ($view->sort as $sort) {
$info = $tables['sorts']['base'][$sort['field']];
if (isset($info['content_field'])) {
$view_content_fields[] = $info['content_field']['field_name'];
}
}
// no need to check arguments : a view with arguments is not cacheable
if (count(array_intersect($view_content_fields, $update_fields))) {
_views_save_view($view);
$updated_views[] = $view->name;
}
}
}
return $updated_views;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment