<% Response.Buffer=true %> <% '----------------------------------------------------------- '-- FUNCTION TO WRITE IA TREE FOR GROUP ACCESS '----------------------------------------------------------- dim selectedNodes dim checkNode dim parent_id dim thisSelectedIDs dim nodesToExpand dim depth parent_id = request("parent_id") thisSelectedIDs = request("thisSelectedIDs") nodesToExpand = request("nodesToExpand") depth = request("depth") call writeCategoryTree(parent_id, thisSelectedIDs, nodesToExpand, depth) function writeCategoryTree(parent_id, thisSelectedIDs, nodesToExpand, depth) dim thisNodeID selectedNodes = Split(thisSelectedIDs,",") openNodes = Split(nodesToExpand,",") gtSQL = ""&_ "SELECT c.*, "&_ "(SELECT count(cc.cat_id) FROM epcms_categories cc WHERE cc.cat_parentid = c.cat_id) as children "&_ "FROM epcms_categories c "&_ "WHERE c.cat_parentid = " & parent_id & " ORDER BY c.cat_name" set rs = LoadRSFromDB(gtSQL) if not rs.EOF then Do While not rs.EOF thisNodeID = rs("cat_id") response.write("
" & VbCrLf) checkNode = false if cint(rs("children")) > 0 then if IDisInArray(thisNodeID,openNodes) then response.write("") else response.write("") end if else response.write("") end if thisNodesDescendants = collectCatDescendants(thisNodeID,"") thisNodesAncestors = collectCatAncestors(thisNodeID,"") response.write("

" & replace(rs("cat_name")," & "," & ") & "

") response.write("

 

" & VbCrLf) response.write("
" & VbCrLf) if IDisInArray(thisNodeID, openNodes) then call writeCategoryTree(thisNodeID, thisSelectedIDs, nodesToExpand, cint(depth + 1)) end if rs.moveNext loop end if rs.Close Set rs = Nothing end function function IDisInArray(c_ID,c_array) dim tempValue tempValue = false if isArray(c_array) then for n=0 to ubound(c_array) if len(c_array(n)) then if cint(c_array(n)) = cint(c_ID) then tempValue = true end if end if next end if IDisInArray = tempValue end function function collectCatDescendants(cat_id,tempString) strSQL = "SELECT cat_id FROM epcms_categories WHERE cat_parentid = " & cat_id set rs = LoadRSFromDB(strSQL) if not rs.EOF then do while not rs.EOF tempString = rs("cat_id") & "||" & tempString call collectCatDescendants(rs("cat_id"),tempString) rs.movenext loop end if rs.Close Set rs = Nothing collectCatDescendants = tempString end function function collectCatAncestors(cat_id,tempString) strSQL = "SELECT cat_parentid FROM epcms_categories WHERE cat_id = " & cat_id set rs = LoadRSFromDB(strSQL) if not rs.EOF then tempString = cat_id & "||" & tempString call collectCatAncestors(rs("cat_parentid"),tempString) end if rs.Close Set rs = Nothing collectCatAncestors = tempString end function %>