Example #1
0
function save_list_selection($conn, $data)
{
    $asset_type = $data['asset_type'];
    $all = $data['all'];
    $assets = $data['assets'];
    $members = $data['save_members'];
    ossim_valid($asset_type, 'asset', 'network', 'group', 'illegal:' . _('Type'));
    ossim_valid($assets, OSS_HEX, OSS_NULLABLE, 'illegal:' . _('Assets'));
    ossim_valid($all, OSS_BINARY, 'illegal:' . _('Asset Selection'));
    ossim_valid($members, OSS_BINARY, OSS_NULLABLE, 'illegal:' . _('Member Selection Option'));
    check_ossim_error();
    //Common error message when the selection is empty
    $empty_msg = sprintf(_('You need to select at least one %s.'), $asset_type);
    //If we filter by manual selection and the asset array is empty
    if (!$all && !is_array($assets)) {
        Av_exception::throw_error(Av_exception::USER_ERROR, $empty_msg);
    }
    $total = Filter_list::save_list_selection($conn, $asset_type, $all, $assets);
    //If the selection is 0
    if ($total < 1) {
        Av_exception::throw_error(Av_exception::USER_ERROR, $empty_msg);
    }
    if ($members) {
        $total = Filter_list::save_members_from_selection($conn, $asset_type);
    }
    return $total;
}