Commit 45507637 authored by RoSk0's avatar RoSk0

Made Dashboard link to appear and hide when checked in config.

parent 7903ba35
......@@ -19,6 +19,7 @@ function crm_core_contact_ui_enable() {
foreach ($menu_items as $item) {
menu_link_save($item);
}
menu_cache_clear_all();
}
/**
......
......@@ -10,6 +10,7 @@ function crm_core_report_enable() {
'weight' => 2,
);
menu_link_save($item);
menu_cache_clear_all();
}
/**
......
......@@ -26,14 +26,6 @@ function crm_core_ui_enable() {
$fields = array( 'module', 'delta', 'theme', 'status', 'weight', 'region', 'custom', 'visibility', 'pages', 'title', 'cache');
$values = array( 'menu', 'crm-core-menu', 'bartik', '1', '0', 'sidebar_first', '0', '0', '', '', '-1');
db_insert('block')->fields($fields, $values)->execute();
$item = array(
'link_path' => 'crm-core',
'link_title' => 'Dashboard',
'menu_name' => 'crm-core-menu',
'weight' => 0,
);
menu_link_save($item);
}
/**
......@@ -41,10 +33,4 @@ function crm_core_ui_enable() {
*/
function crm_core_ui_disable() {
db_delete('block')->condition('delta', 'crm-core-menu')->execute();
$links = menu_load_links('crm-core-menu');
foreach ($links as $link) {
if ($link['link_path'] == 'crm-core') {
menu_link_delete($link['mlid']);
}
}
}
......@@ -13,7 +13,7 @@ function crm_core_ui_menu() {
'title' => 'CRM Core',
'page callback' => 'crm_core_ui_dashboard',
'access arguments' => array('view crm dashboard'),
'type' => MENU_NORMAL_ITEM,
'type' => MENU_SUGGESTED_ITEM,
'theme callback' => 'crm_core_ui_get_theme',
);
......
......@@ -116,6 +116,7 @@ function crm_core_ui_admin_config_form($form, &$form_state) {
'!theme_settings' => l(t('theme settings'), 'admin/appearance/settings'),
)),
);
$form['#submit'][] = 'crm_core_ui_admin_config_form_submit';
return system_settings_form($form);
}
......@@ -138,3 +139,28 @@ function crm_core_ui_admin_config_form_validate($form, &$form_state) {
form_set_error('crm_core_theme', t('You must select a theme to use.'));
}
}
/**
* Submit handler for CRM Core settings form.
*/
function crm_core_ui_admin_config_form_submit($form, &$form_state) {
$dashboard_enabled = $form_state['values']['crm_core_dashboard_enabled'];
if ($dashboard_enabled) {
$item = array(
'link_path' => 'crm-core/dashboard',
'link_title' => 'Dashboard',
'menu_name' => 'crm-core-menu',
'weight' => 0,
);
menu_link_save($item);
menu_cache_clear_all();
}
else {
$links = menu_load_links('crm-core-menu');
foreach ($links as $link) {
if ($link['link_path'] == 'crm-core/dashboard') {
menu_link_delete($link['mlid']);
}
}
}
}
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