Skip to content

Commit

Permalink
Cover more use cases
Browse files Browse the repository at this point in the history
  • Loading branch information
richard67 committed Jun 11, 2017
1 parent 035ff92 commit 0bee4b3
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 19 deletions.
Expand Up @@ -26,17 +26,39 @@ UPDATE `#__menu_types`
-- Step 2: What remains now are the main menu items, possibly with wrong
-- client_id if there was nothing hit by step 1 because there was no record in
-- the menu types table with client_id = 0.
-- If there is a record in the menutype table we don't care because either
-- it has client_id 1, then it is ok, or it does not exist (which is the normal
-- case for the standard main menu).
UPDATE `#__menu`
SET `client_id` = 1
WHERE `menutype` = 'main';

-- Step 3: Synch menu type "menu" correct client_id if there is no user-defined
-- menu type "menu" for either admin or site.
-- Step 3: If we have menu items for the admin using menutype = "menu" and
-- having correct client_id = 1, we can be sure they belong to the admin menu
-- and so rename the menutype.
UPDATE `#__menu`
SET `menutype` = 'main'
WHERE `client_id` = 1
AND `menutype` = 'menu';

-- Step 4: If there is no user-defined menu type "menu" for the site, we can
-- assume that any menu items for that menu type belong to the admin.
-- Fix the client_id for those as it was done with the original version of this
-- schema update script here.
UPDATE `#__menu`
SET `menutype` = 'main',
`client_id` = 1
WHERE `menutype` = 'menu'
AND (SELECT COUNT(`id`) FROM `#__menu_types` WHERE `menutype` = 'menu') = 0;
AND (SELECT COUNT(`id`) FROM `#__menu_types` WHERE `client_id` = 0 AND `menutype` = 'menu') = 0;

-- Step 5: For the standard admin menu items of menutype "main" there is no record
-- in the menutype table on a clean Joomla installation. If there is one, it is a
-- mistake and it should be deleted, but here we rename it so the admin can see
-- it and delete it then. This is also to be done with menu type "menu" for the
-- admin which we renamed before in step 3.
UPDATE `#__menu_types`
SET `menutype` = 'main_to_be_deleted'
WHERE `client_id` = 1
AND `menutype` = 'main';

UPDATE `#__menu_types`
SET `menutype` = 'menu_to_be_deleted'
WHERE `client_id` = 1
AND `menutype` = 'menu';
Expand Up @@ -26,17 +26,39 @@ UPDATE "#__menu_types"
-- Step 2: What remains now are the main menu items, possibly with wrong
-- client_id if there was nothing hit by step 1 because there was no record in
-- the menu types table with client_id = 0.
-- If there is a record in the menutype table we don't care because either
-- it has client_id 1, then it is ok, or it does not exist (which is the normal
-- case for the standard main menu).
UPDATE "#__menu"
SET "client_id" = 1
WHERE "menutype" = 'main';
WHERE `menutype` = 'main';

-- Step 3: Synch menu type "menu" correct client_id if there is no user-defined
-- menu type "menu" for either admin or site.
-- Step 3: If we have menu items for the admin using menutype = "menu" and
-- having correct client_id = 1, we can be sure they belong to the admin menu
-- and so rename the menutype.
UPDATE "#__menu"
SET "menutype" = 'main'
WHERE "client_id" = 1
AND "menutype" = 'menu';

-- Step 4: If there is no user-defined menu type "menu" for the site, we can
-- assume that any menu items for that menu type belong to the admin.
-- Fix the client_id for those as it was done with the original version of this
-- schema update script here.
UPDATE "#__menu"
SET "menutype" = 'main',
"client_id" = 1
WHERE "menutype" = 'menu'
AND (SELECT COUNT("id") FROM "#__menu_types" WHERE "menutype" = 'menu') = 0;
AND (SELECT COUNT("id") FROM "#__menu_types" WHERE "client_id" = 0 AND "menutype" = 'menu') > 0;

-- Step 5: For the standard admin menu items of menutype "main" there is no record
-- in the menutype table on a clean Joomla installation. If there is one, it is a
-- mistake and it should be deleted, but here we rename it so the admin can see
-- it and delete it then. This is also to be done with menu type "menu" for the
-- admin which we renamed before in step 3.
UPDATE "#__menu_types"
SET "menutype" = 'main_to_be_deleted'
WHERE "client_id" = 1
AND "menutype" = 'main';

UPDATE "#__menu_types"
SET "menutype" = 'menu_to_be_deleted'
WHERE "client_id" = 1
AND "menutype" = 'menu';
Expand Up @@ -25,20 +25,42 @@ UPDATE [#__menu_types]
-- Step 2: What remains now are the main menu items, possibly with wrong
-- client_id if there was nothing hit by step 1 because there was no record in
-- the menu types table with client_id = 0.
-- If there is a record in the menutype table we don't care because either
-- it has client_id 1, then it is ok, or it does not exist (which is the normal
-- case for the standard main menu).
UPDATE [#__menu]
SET [client_id] = 1
WHERE [menutype] = 'main';

-- Step 3: Synch menu type "menu" correct client_id if there is no user-defined
-- menu type "menu" for either admin or site.
-- Step 3: If we have menu items for the admin using menutype = "menu" and
-- having correct client_id = 1, we can be sure they belong to the admin menu
-- and so rename the menutype.
UPDATE [#__menu]
SET [menutype] = 'main'
WHERE [client_id] = 1
AND [menutype] = 'menu';

-- Step 4: If there is no user-defined menu type "menu" for the site, we can
-- assume that any menu items for that menu type belong to the admin.
-- Fix the client_id for those as it was done with the original version of this
-- schema update script here.
UPDATE [#__menu]
SET [menutype] = 'main',
[client_id] = 1
WHERE [menutype] = 'menu'
AND (SELECT COUNT([id]) FROM [#__menu_types] WHERE [menutype] = 'menu') = 0;
AND (SELECT COUNT([id]) FROM [#__menu_types] WHERE [client_id] = 0 AND [menutype] = 'menu') > 0;

-- Step 5: For the standard admin menu items of menutype "main" there is no record
-- in the menutype table on a clean Joomla installation. If there is one, it is a
-- mistake and it should be deleted, but here we rename it so the admin can see
-- it and delete it then. This is also to be done with menu type "menu" for the
-- admin which we renamed before in step 3.
UPDATE [#__menu_types]
SET [menutype] = 'main_to_be_deleted'
WHERE [client_id] = 1
AND [menutype] = 'main';

UPDATE [#__menu_types]
SET [menutype] = 'menu_to_be_deleted'
WHERE [client_id] = 1
AND [menutype] = 'menu';

-- End sync menutype for admin menu and set client_id correct

Expand Down

0 comments on commit 0bee4b3

Please sign in to comment.