Hi,
I created a dynamic menu based on my database pursuant to the Scriptcase tutorial. Here’s my working code located in AppInit and OnLoad events:
//======================Preparation
sc_reset_menu_disable();
sc_reset_menu_delete();
sc_appmenu_reset(‘main_menu’);
//======================Dynamic Menu Creation
sc_appmenu_create(‘main_menu’);
sc_lookup(dsmenu,"
SELECT
id,
parent_item,
label,
application,
parameters,
icon,
hint,
target
FROM
main_menu
ORDER BY
parent_item ASC,
node_order ASC,
label ASC");
foreach({dsmenu} as $arr_menu)
{
$item_id = $arr_menu[0];
$menu_item_id = 'item_'.$arr_menu[0];
if($arr_menu[1] == 0)
{
$parent_item = "";
}
else
{
$parent_item = 'item_'.$arr_menu[1];
}
sc_appmenu_add_item(‘main_menu’,
$menu_item_id,
$parent_item,
$arr_menu[2],
$arr_menu[3],
“”,
$arr_menu[5],
$arr_menu[6],
$arr_menu[7]);
}
//====================== Delete menu items not accessible to the user_group
sc_select(rs, "
SELECT id
FROM main_menu
WHERE id != ‘0’ AND id != 1 AND application IN (SELECT app_name FROM groups_apps WHERE group_id = ‘".[glo_group_id]."’ AND priv_access IS NULL) AND id NOT IN (SELECT parent_item FROM main_menu WHERE parent_item != ‘’)
");
while(!$rs->EOF)
{
$del_item = 'item_'.$rs->fields[0];
sc_appmenu_remove_item ('main_menu', $del_item);
$rs->MoveNext();
}
$rs->Close();
I need to have it automatically delete/remove menu items that fall under the following criteria:
- Auto delete menu items that the user group has no access in the linked applications per Scriptcase Security Module generated tables (do not forget to enable security module in “My Scriptcase” option);
- Auto delete menu items (node) that has no active/existing submenu items – when all submenu items were already automatically deleted per criteria #1;
- Auto delete menu items (which are not node) that has no linked application.
Any help would be greatly appreciated. I’ve been trying to solve this for weeks now and it’s badly needed. Thanks in advance!
–Mister Grey
PS. I only studied programming via online tutorials so please bear with me.