function get_policy_actions($conn, $data) { $ctx = empty($data['ctx']) ? Session::get_default_ctx() : $data['ctx']; $id = $data['id']; ossim_valid($ctx, OSS_HEX, 'illegal:' . _("CTX")); ossim_valid($id, OSS_HEX, OSS_NULLABLE, 'illegal:' . _("CTX")); if (ossim_error()) { $info_error = "Error: " . ossim_get_error(); ossim_clean_error(); $return['error'] = TRUE; $return['msg'] = $info_error; return $return; } $actions_saved = array(); $result = ''; if ($action_list = Policy_action::get_list($conn, $id)) { foreach ($action_list as $action) { $actions_saved[] = $action->get_action_id(); } } $where = Session::Am_i_admin() ? '' : "AND ctx=UNHEX('{$ctx}')"; if ($action_list2 = Action::get_list($conn, $where)) { foreach ($action_list2 as $act) { $sel = in_array($act->get_id(), $actions_saved) ? " selected='selected'" : ""; $desc1 = strlen($act->get_name()) > 48 ? substr($act->get_name(), 0, 48) . "..." : $act->get_name(); $result .= "<option value='" . $act->get_id() . "' {$sel}>{$desc1}</option>"; } } $return['error'] = FALSE; $return['data'] = $result; return $return; }
Policy::update($conn, $id, $ctx, $priority, $active, $group, $order, $tzone, $b_month, $b_month_day, $b_week_day, $b_hour, $b_minute, $e_month, $e_month_day, $e_week_day, $e_hour, $e_minute, $descr, $source_ips, $source_host_groups, $dest_ips, $dest_host_groups, $source_nets, $source_net_groups, $dest_nets, $dest_net_groups, $portsrc, $portdst, $plug_groups, $sensors, $target, $taxonomy, $reputation, $event_conds, $idm, $correlate, $cross_correlate, $store, $rep, $qualify, $resend_alarms, $resend_events, $frw_conds, $sign, $sem, $sim); // Actions if (count($policy_action) > 0) { Policy_action::delete($conn, $id); foreach ($policy_action as $action_id) { Policy_action::insert($conn, $action_id, $id); } } break; case 'clone': $order = Policy::get_next_order($conn, $ctx, $group); $newid = Policy::insert($conn, $ctx, $priority, $active, $group, $order, $tzone, $b_month, $b_month_day, $b_week_day, $b_hour, $b_minute, $e_month, $e_month_day, $e_week_day, $e_hour, $e_minute, $descr, $source_ips, $source_host_groups, $dest_ips, $dest_host_groups, $source_nets, $source_net_groups, $dest_nets, $dest_net_groups, $portsrc, $portdst, $plug_groups, $sensors, $target, $taxonomy, $reputation, $event_conds, $idm, $correlate, $cross_correlate, $store, $rep, $qualify, $resend_alarms, $resend_events, $frw_conds, $sign, $sem, $sim); // Actions if (!empty($newid) && count($policy_action) > 0) { foreach ($policy_action as $action_id) { Policy_action::insert($conn, $action_id, $newid); } } break; default: die(_('Wrong option chosen')); } $db->close(); ?> <p> <?php echo _("Policy successfully inserted"); ?> </p> <script>document.location.href="policy.php"</script>