예제 #1
0
 list($assets, $total_assets) = Asset_host::get_list($conn, '', array('limit' => 1));
 //Number of selected assets
 $total_selected = Filter_list::get_total_selection($conn, 'asset');
 //Remove asset selection
 Filter_list::clean_selection($conn);
 //Getting the object with the filters.
 $filters = Filter_list::retrieve_filter_list_session();
 $filters->empty_filter_search($conn);
 if ($filters === FALSE) {
     $exp_msg = _('Sorry, operation was not completed due to an error when processing the request');
     Av_exception::throw_error(Av_exception::USER_ERROR, $exp_msg);
 }
 if ($total_selected == $total_assets) {
     //All assets were selected, so we filter them by OS
     $os_filters = array('where' => '(host_properties.value NOT LIKE "windows%" AND host_properties.value NOT LIKE "microsoft%")');
     list($os_list, $total_os) = Asset_host_properties::get_property_values($conn, 3, $os_filters);
     $filters->modify_filter(20, 'unknown', 0);
     foreach ($os_list as $os_key => $os_value) {
         $filters->modify_filter(20, $os_value, 0);
     }
 } else {
     //Not all assets were selected, so we filter by asset
     //Getting assets with unknown or Linux/UNIX Operating System
     $tables = 'LEFT JOIN host_properties hp ON hp.host_id=host.id AND hp.property_ref=3 INNER JOIN user_component_filter f ON f.asset_id = host.id';
     $os_filters = array('where' => '((hp.host_id IS NULL OR hp.value IS NULL OR hp.value LIKE "%unknown%") OR (hp.value NOT LIKE "windows%" AND hp.value NOT LIKE "microsoft%"))
                     AND f.asset_type="asset" AND f.session_id = "' . session_id() . '"');
     $unsupported_assets = Asset_host::get_list_tree($conn, $tables, $os_filters, FALSE, TRUE);
     foreach ($unsupported_assets as $a_data) {
         $filters->modify_filter(11, $a_data[2], 0);
     }
 }
예제 #2
0
function model_list($conn, $page, $search)
{
    $filters = array();
    $filters['limit'] = get_query_limits($page);
    if ($search != '') {
        $search = utf8_decode($search);
        $search = escape_sql($search, $conn);
        $filters['where'] = " host_properties.value LIKE '%{$search}%' ";
    }
    try {
        list($properties, $total) = Asset_host_properties::get_property_values($conn, 14, $filters, TRUE);
    } catch (Exception $e) {
        $return['error'] = TRUE;
        $return['msg'] = $e->getMessage();
        return $return;
    }
    if ($total > 0) {
        $selected = get_selected_values(21);
    }
    $list = array();
    //Going through the list to format the elements properly:
    foreach ($properties as $os_id => $value) {
        $_chk = $selected[$os_id] != '' ? TRUE : FALSE;
        $_prop = array('id' => $value, 'name' => $value, 'checked' => $_chk);
        $list[$os_id] = $_prop;
    }
    $data['total'] = intval($total);
    $data['list'] = $list;
    $return['error'] = FALSE;
    $return['data'] = $data;
    return $return;
}