function validate_post_params($conn, $name, $descr, $sids, $imported_sids)
{
    $vals = array('name' => array(OSS_INPUT, 'illegal:' . _("Name")), 'descr' => array(OSS_TEXT, OSS_NULLABLE, 'illegal:' . _("Description")));
    ossim_valid($name, $vals['name']);
    ossim_valid($descr, $vals['descr']);
    $plugins = array();
    $sids = is_array($sids) ? $sids : array();
    if (intval(POST('pluginid')) > 0) {
        $sids[POST('pluginid')] = "0";
    }
    foreach ($sids as $plugin => $sids_str) {
        if ($sids_str !== '') {
            list($valid, $data) = Plugin_sid::validate_sids_str($sids_str);
            if (!$valid) {
                ossim_set_error(_("Error for data source ") . $plugin . ': ' . $data);
                break;
            }
            if ($sids_str == "ANY") {
                $sids_str = "0";
            } else {
                $aux = count(explode(',', $sids_str));
                $total = Plugin_sid::get_sidscount_by_id($conn, $plugin);
                $sids_str = $aux == $total ? "0" : $sids_str;
            }
            $plugins[$plugin] = $sids_str;
        }
    }
    if (!count($plugins) && !count($imported_sids)) {
        ossim_set_error(_("No Data Sources or Event Types selected"));
    }
    if (ossim_error()) {
        die(ossim_error());
    }
    return array($name, $descr, $plugins);
}
Ejemplo n.º 2
0
function modify_plugingroup_plugin($conn, $data)
{
    $plugin_group = $data['plugin_group'];
    $plugin_id = $data['plugin_id'];
    $sids_str = $data['plugin_sids'];
    ossim_valid($plugin_id, OSS_DIGIT, 'illegal:' . _("Plugin ID"));
    ossim_valid($plugin_group, OSS_HEX, 'illegal:' . _("Plugin GroupID"));
    if (ossim_error()) {
        $info_error = "Error: " . ossim_get_error();
        ossim_clean_error();
        $return['error'] = true;
        $return['msg'] = $info_error;
        return $return;
    }
    $total_sel = 1;
    if (is_array($sids_str)) {
        $total_sel = count($sids_str);
        $sids_str = implode(',', $sids_str);
    }
    if ($sids_str !== '') {
        list($valid, $data) = Plugin_sid::validate_sids_str($sids_str);
        if (!$valid) {
            $return['error'] = true;
            $return['msg'] = _("Error for data source ") . $plugin_id . ': ' . $data;
            return $return;
        }
        if ($sids_str == "ANY") {
            $sids_str = "0";
        } else {
            $total = Plugin_sid::get_sidscount_by_id($conn, $plugin_id);
            $sids_str = $total_sel == $total ? "0" : $sids_str;
        }
        Plugin_group::edit_plugin($conn, $plugin_group, $plugin_id, $sids_str);
    }
    $return['error'] = false;
    $return['output'] = '';
    return $return;
}
Ejemplo n.º 3
0
function validate_post_params($conn, $name, $descr, $sids, $imported_sids, $group_id = NULL)
{
    $vals = array('name' => array(OSS_INPUT, 'illegal:' . _("Name")), 'descr' => array(OSS_ALL, OSS_NULLABLE, 'illegal:' . _("Description")), 'group_id' => array(OSS_HEX, OSS_NULLABLE, 'illegal:' . _("Group ID")));
    ossim_valid($group_id, $vals['group_id']);
    ossim_valid($name, $vals['name']);
    if (ossim_error() == FALSE && Plugin_group::is_valid_group_name($conn, $name, $group_id) == FALSE) {
        $name = Util::htmlentities($name);
        ossim_set_error(sprintf(_("DS group name '<strong>%s</strong>' already exists"), $name));
    }
    ossim_valid($descr, $vals['descr']);
    $plugins = array();
    $sids = is_array($sids) ? $sids : array();
    $pluginid = intval(POST('pluginid'));
    if ($pluginid > 0) {
        $sids[$pluginid] = "0";
    }
    foreach ($sids as $plugin => $sids_str) {
        if ($sids_str !== '') {
            list($valid, $data) = Plugin_sid::validate_sids_str($sids_str);
            if (!$valid) {
                ossim_set_error(_("Error for data source ") . $plugin . ': ' . $data);
                break;
            }
            if ($sids_str == "ANY") {
                $sids_str = "0";
            } else {
                $aux = count(explode(',', $sids_str));
                $total = Plugin_sid::get_sidscount_by_id($conn, $plugin);
                $sids_str = $aux == $total ? "0" : $sids_str;
            }
            $plugins[$plugin] = $sids_str;
        }
    }
    if (!count($plugins) && !count($imported_sids)) {
        ossim_set_error(_("No Data Sources or Event Types selected"));
    }
    return array($group_id, $name, $descr, $plugins, ossim_error());
}