Line 527:

    $queryStr = "left join {content_type_%s} ct  on n.nid=ct.nid
                 left join {node_type} nt on n.type=nt.type ";

This doesn't accomplish anything. The node_type table has data about the actual content types, not nodes. And the query doesn't seem to be pulling in any fields from the table anyway.