function &getCategoriesWithOpenQuestion($limit = 0, $start = 0, $parentid = 0, $sort = 'weight', $order = 'ASC') { include_once XOOPS_ROOT_PATH . '/modules/smartfaq/include/functions.php'; $criteria = new CriteriaCompo(); $criteria->setSort($sort); $criteria->setOrder($order); if ($parentid != -1) { $criteria->add(new Criteria('c.parentid', $parentid)); } if (!sf_userIsAdmin()) { $smartPermHandler =& xoops_getmodulehandler('permission', 'smartfaq'); $categoriesGranted = $smartPermHandler->getPermissions('category'); $criteria->add(new Criteria('categoryid', "(" . implode(',', $categoriesGranted) . ")", 'IN')); } $criteria->add(new Criteria('f.status', _SF_STATUS_OPENED)); $criteria->setStart($start); $criteria->setLimit($limit); $ret = array(); $limit = $start = 0; $sql = 'SELECT DISTINCT c.categoryid, c.parentid, c.name, c.description, c.total, c.weight, c.created FROM ' . $this->db->prefix('smartfaq_categories') . ' AS c INNER JOIN ' . $this->db->prefix('smartfaq_faq') . ' AS f ON c.categoryid = f.categoryid'; if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { $sql .= ' ' . $criteria->renderWhere(); if ($criteria->getSort() != '') { $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder(); } $limit = $criteria->getLimit(); $start = $criteria->getStart(); } //echo "<br />" . $sql . "<br />"; $result = $this->db->query($sql, $limit, $start); if (!$result) { return $ret; } while ($myrow = $this->db->fetchArray($result)) { $category = new sfCategory(); $category->assignVars($myrow); $ret[] =& $category; unset($category); } return $ret; }