Example #1
0
function GetAllChildren($category_id, &$children)
{
    global $DB;
    $result = $DB->Query('SELECT * FROM lx_categories WHERE parent_id=?', array($category_id));
    while ($category = $DB->NextRow($result)) {
        $children[$category['category_id']] = 1;
        GetAllChildren($category['category_id'], $children);
    }
    $DB->Free($result);
}
Example #2
0
function SetupQualifier()
{
    global $configuration, $DB;
    $qualifier = '';
    $wheres = array();
    // Scan only links with a specific status
    if (is_array($configuration['status'])) {
        $wheres[] = "status IN ('" . join("','", array_keys($configuration['status'])) . "')";
    }
    // Scan only links of a specific type
    if (is_array($configuration['type'])) {
        $wheres[] = "type IN ('" . join("','", array_keys($configuration['type'])) . "')";
    }
    // Configure date added range to scan
    if (!IsEmptyString($configuration['date_added_start']) && !IsEmptyString($configuration['date_added_end'])) {
        $wheres[] = "date_added BETWEEN '{$configuration['date_added_start']}' AND '{$configuration['date_added_end']}'";
    }
    // Configure date modified range to scan
    if (!IsEmptyString($configuration['date_modified_start']) && !IsEmptyString($configuration['date_modified_end'])) {
        $wheres[] = "date_modified BETWEEN '{$configuration['date_modified_start']}' AND '{$configuration['date_modified_end']}'";
    }
    // Configure date scanned range to scan
    if (!IsEmptyString($configuration['date_scanned_start']) && !IsEmptyString($configuration['date_scanned_end'])) {
        $wheres[] = "date_scanned BETWEEN '{$configuration['date_scanned_start']}' AND '{$configuration['date_scanned_end']}'";
    }
    // Configure categories to scan
    if (!empty($configuration['category_id'])) {
        $categories = array($configuration['category_id'] => 1);
        foreach (explode(',', $configuration['category_id']) as $category_id) {
            GetAllChildren($category_id, $categories);
        }
        $wheres[] = "category_id IN (" . join(',', array_keys($categories)) . ")";
    }
    if (count($wheres) > 0) {
        $qualifier = "WHERE " . join(' AND ', $wheres);
    }
    return $qualifier;
}