Guest User

Untitled

a guest
Mar 13th, 2018
14
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT /* B1B24D711AF049D8A739B9DE73354CCF46708BDC-26BB-4DB5-AF4064C996F0F5FCgetfoldersfortree */ folder_id, folder_name, folder_id_r, folder_of_user, folder_owner, folder_level, in_trash,link_path, username, perm, subhere, permfolder
  2. FROM (
  3. SELECT f.folder_id, f.folder_id_r, f.folder_of_user, f.folder_owner, f.folder_level,f.in_trash,f.link_path, IFNULL(u.user_login_name,'Obsolete') AS username,
  4.  f.folder_name, 'unlocked' AS perm,
  5. CASE WHEN EXISTS(
  6. SELECT *
  7. FROM raz1_folders s1
  8. WHERE s1.folder_id != f.folder_id AND s1.folder_id_r = f.folder_id AND s1.in_trash = 'F' AND s1.host_id = 1
  9. LIMIT 1
  10.  
  11. ) THEN 1 WHEN EXISTS(
  12. SELECT *
  13. FROM raz1_folders s2, raz1_folders_groups fg3
  14. WHERE s2.folder_id != f.folder_id AND s2.host_id = 1 AND s2.in_trash = 'F' AND fg3.host_id = s2.host_id AND s2.folder_id_r = f.folder_id AND fg3.folder_id_r = s2.folder_id AND fg3.grp_permission IN ('r','w','x') AND fg3.grp_id_r IN ('1')
  15. LIMIT 1
  16.  
  17. ) THEN 1 WHEN EXISTS(
  18. SELECT *
  19. FROM raz1_folders s3, raz1_folders_groups fg4
  20. WHERE s3.folder_id != f.folder_id AND s3.folder_id_r = f.folder_id AND s3.in_trash = 'F' AND fg4.grp_id_r = '0' AND fg4.folder_id_r = s3.folder_id AND fg4.grp_permission IN ('r','w','x') AND s3.host_id = 1 AND s3.host_id = fg4.host_id
  21. LIMIT 1
  22.  
  23. ) THEN 1 ELSE 0 END AS subhere
  24.  
  25.  
  26. , 'X' AS permfolder
  27. FROM raz1_folders f
  28. LEFT JOIN users u ON u.user_id = f.folder_owner
  29. WHERE
  30.  
  31.  f.folder_id = f.folder_id_r AND (f.folder_is_collection IS NULL OR folder_is_collection = '') AND f.host_id = 1
  32. ) AS itb
  33. WHERE itb.perm = 'unlocked'
  34. ORDER BY folder_name
RAW Paste Data