Skip to content

Instantly share code, notes, and snippets.

@gene1wood
Created November 29, 2013 23:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gene1wood/7713388 to your computer and use it in GitHub Desktop.
Save gene1wood/7713388 to your computer and use it in GitHub Desktop.
This query will help in the Gallery 2 to Gallery 3 migration process. With it you can find all photos which do not have the "[core] view item" permission and which are not part of an album which also does not have the "[core] view item" permission. These photos will be publicly viewable in gallery 3 unlike gallery 2 where they were private. This…
# Find all photos which do not have the "[core] view item" permission
# and which are not part of an album which also does not have the
# "[core] view item" permission. These photos will be publicly viewable
# in gallery 3 unlike gallery 2
CREATE TEMPORARY TABLE restricted_items
SELECT DISTINCT(
TRIM(TRAILING '/' FROM
SUBSTRING_INDEX(
g2_ItemAttributesMap.g_parentSequence,
'/',
-2
)
)
) AS g_parent,
g2_Item.g_title AS g_title,
g2_AccessMap.g_permission AS g_permission,
g2_Item.g_canContainChildren AS g_canContainChildren,
g2_Item.g_id AS g_id
FROM
g2_AccessMap,
g2_AccessSubscriberMap,
g2_Item,
g2_ItemAttributesMap
WHERE
g2_AccessMap.g_accessListId = g2_AccessSubscriberMap.g_accessListId AND
g2_AccessSubscriberMap.g_itemId = g2_Item.g_id AND
g2_AccessSubscriberMap.g_itemId = g2_ItemAttributesMap.g_itemId AND
g2_AccessMap.g_userOrGroupId = 4 AND
g2_AccessMap.g_permission % 2 = 0;
CREATE TEMPORARY TABLE restricted_folders
SELECT g2_Item.g_id AS g_id
FROM
g2_AccessMap,
g2_AccessSubscriberMap,
g2_Item,
g2_ItemAttributesMap
WHERE
g2_AccessMap.g_accessListId = g2_AccessSubscriberMap.g_accessListId AND
g2_AccessSubscriberMap.g_itemId = g2_Item.g_id AND
g2_AccessSubscriberMap.g_itemId = g2_ItemAttributesMap.g_itemId AND
g2_Item.g_canContainChildren = 1 AND
g2_AccessMap.g_userOrGroupId = 4 AND
g2_AccessMap.g_permission % 2 = 0;
SELECT restricted_items.g_id,
restricted_items.g_title,
restricted_items.g_parent,
restricted_items.g_permission
FROM restricted_items
LEFT JOIN restricted_folders
ON restricted_items.g_parent = restricted_folders.g_id
WHERE restricted_folders.g_id IS Null AND
g_canContainChildren = 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment