function view_custom_table_all_available_custom_tables_for_views in Views Custom Table 7
Function to list all available custom tables for views.
1 string reference to 'view_custom_table_all_available_custom_tables_for_views'
- view_custom_table_menu in ./
view_custom_table.module - Implements hook_menu().
File
- ./
view_custom_table.admin.inc, line 412 - File for administrative functions.
Code
function view_custom_table_all_available_custom_tables_for_views() {
if (db_table_exists('custom_table_view_data')) {
drupal_add_css(drupal_get_path('module', 'views') . '/css/views-admin.seven.css', array(
'group' => CSS_THEME,
'every_page' => TRUE,
'weight' => 10,
));
drupal_add_css(drupal_get_path('module', 'views') . '/css/views-admin.ctools.css', array(
'group' => CSS_THEME,
'every_page' => TRUE,
'weight' => 10,
));
$query = db_select('custom_table_view_data', 'ctvd');
$query
->leftJoin('users', 'u', 'u.uid = ctvd.created_by');
$query
->fields('ctvd', array(
'table_name',
'description',
'id',
));
$query
->fields('u', array(
'name',
'uid',
));
$query
->orderBy('ctvd.table_name');
$all_custom_tables = $query
->execute()
->fetchAll();
if (!empty($all_custom_tables)) {
foreach ($all_custom_tables as $key => $custom_table) {
$links = array(
array(
'title' => t('Edit'),
'href' => 'admin/structure/views/custom_table/' . $custom_table->id . '/edit',
),
array(
'title' => t('Views'),
'href' => 'admin/structure/views/custom_table/' . $custom_table->id . '/views',
),
array(
'title' => t('Relations'),
'href' => 'admin/structure/views/custom_table/' . $custom_table->id . '/relations',
),
array(
'title' => t('Delete'),
'href' => 'admin/structure/views/custom_table/' . $custom_table->id . '/delete',
),
);
$rows[] = array(
$key,
$custom_table->table_name,
$custom_table->description,
l(t('@user_name', array(
"@user_name" => $custom_table->name,
)), 'user/' . $custom_table->uid),
theme('links__ctools_dropbutton', array(
'links' => $links,
)),
);
}
$headers = array(
'#',
t('Table Name'),
t('Description'),
t('Created By'),
t('Oprations'),
);
$output = theme('table', array(
'header' => $headers,
'rows' => $rows,
));
}
else {
$output = "<h2 style='text-align:center;'>No Tables Available.</h2>";
}
}
else {
$output = "";
drupal_set_message(t('"Views Custom Table" module is not installed properly, Please reinstall install it and try again.'), 'error');
}
return $output;
}