get('aid', 0); $wheres[] = " a.id = " . (int) $wb_id; $wheres[] = " a.id = b.wb_id "; $wheres[] = " b.ws_id = c.id "; $wheres[] = " c.published=1 "; $wheres[] = " a.section=d.id "; $wheres[] = " a.category=e.id "; $wheres[] = " e.published=1 "; if ($aid !== null) { $wheres[] = "a.access <= " . (int) $aid; $wheres[] = "c.access <= " . (int) $aid; $wheres[] = "d.access <= " . (int) $aid; $wheres[] = "e.access <= " . (int) $aid; } $query = " SELECT c.id, c.sheetname, a.link_title as wbtitle, c.nr_parms, c.parms " . " FROM #__sql2excel_workbooks a, #__sql2excel_worksheet2book b, #__sql2excel_worksheets c, #__sql2excel_sections d, #__sql2excel_categories e " . " WHERE " . implode( " AND ", $wheres ) . " ORDER BY b.ordering"; $db->setQuery( $query ); $worksheets = $db->loadObjectList(); return $worksheets; } }