View source
<?php
include_once 'includes/total_control.inc';
include_once 'includes/total_control.views_default.inc';
define('TOTAL_CONTROL_REQUIRED_PANELS_API', '3');
define('TOTAL_CONTROL_REQUIRED_VIEWS_API', '2');
define('TOTAL_CONTROL_DASHBOARD_PANEL_NAME', 'dashboard');
define('TOTAL_CONTROL_MINIMUM_VERSION', 2);
define('TOTAL_CONTROL_VERSION', 2);
function total_control_permission() {
return array(
'have total control' => array(
'title' => t('Have total control'),
'description' => t('See the Total Control administrative dashboard.'),
),
'administer total control' => array(
'title' => t('Administer total control'),
'description' => t('Adjust the settings for the Total Control administrative dashboard.'),
),
);
}
function total_control_menu() {
$items = array();
$items['admin/config/administration/control'] = array(
'title' => 'Total Control Dashboard',
'description' => 'Adjust dashboard settings.',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'total_control_admin_settings',
),
'access arguments' => array(
'administer total control',
),
'file' => 'total_control.admin.inc',
);
$items['admin/dashboard/overview'] = array(
'title' => 'Dashboard',
'description' => 'Total Control admin dashboard',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -100,
);
return $items;
}
function total_control_menu_local_tasks_alter(&$data, $router_item, $root_path) {
if ($router_item['page_callback'] == 'views_page' && $router_item['page_arguments'][0] == 'control_content') {
if ($router_item['page_arguments'][1]) {
$pattern = '/^page_tc_([\\S]*)/';
if (preg_match($pattern, $router_item['page_arguments'][1], $matches)) {
$content_type = node_type_get_type($matches[1]);
if (user_access('create ' . $content_type->type . ' content')) {
$type_url_str = str_replace('_', '-', $content_type->type);
$item = menu_get_item('node/add/' . $type_url_str);
$item['title'] = t('Add %type', array(
'%type' => $content_type->name,
));
if ($item['access']) {
$data['actions']['output'][] = array(
'#theme' => 'menu_local_action',
'#link' => $item,
);
}
}
}
}
}
}
function total_control_form_alter(&$form, $form_state, $form_id) {
if ('node_type_form' == $form_id) {
$form['#submit'][] = 'total_control_add_type_submit';
}
if ('node_type_delete_confirm' == $form_id) {
$form['#submit'][] = 'total_control_remove_type_submit';
}
}
function total_control_user_login(&$edit, $account) {
if (!(arg(0) == 'user' && arg(1) == 'reset')) {
if (user_access('have total control', $account)) {
if (variable_get('total_control_login_redirect', 0) == 1) {
$_GET['destination'] = 'admin/dashboard';
}
}
}
}
function total_control_ctools_plugin_directory($module, $plugin) {
if ($module == 'ctools' && !empty($plugin)) {
return "plugins/{$plugin}";
}
}
function total_control_ctools_plugin_api($module, $api) {
if ($module == 'panels_mini' && $api == 'panels_default') {
return array(
'version' => 1,
);
}
if ($module == 'page_manager' && $api == 'pages_default') {
return array(
'version' => 1,
);
}
}
function total_control_views_api() {
return array(
'api' => 2,
);
}
function total_control_theme() {
return array(
'total_control_create' => array(
'variables' => array(
'create' => array(),
),
'file' => 'total_control.theme.inc',
),
'total_control_overview' => array(
'variables' => array(
'content' => array(),
'users' => array(),
),
'file' => 'total_control.theme.inc',
),
'total_control_overview_content' => array(
'variables' => array(
'overview' => array(),
),
'file' => 'total_control.theme.inc',
),
'total_control_overview_user' => array(
'variables' => array(
'overview' => array(),
),
'file' => 'total_control.theme.inc',
),
'total_control_admin_table' => array(
'variables' => array(
'header' => array(),
'rows' => array(),
'link' => FALSE,
),
'file' => 'total_control.theme.inc',
),
);
}