'Delete', 2 => 'Duplicate' ); /* set default action */ if (!isset($_REQUEST['action'])) { $_REQUEST['action'] = ''; } switch ($_REQUEST['action']) { case 'save': form_save(); break; case 'actions': form_actions(); break; case 'item_movedown': item_movedown(); header('Location: cdef.php?action=edit&id=' . $_REQUEST['cdef_id']); break; case 'item_moveup': item_moveup(); header('Location: cdef.php?action=edit&id=' . $_REQUEST['cdef_id']); break; case 'item_remove': item_remove(); header('Location: cdef.php?action=edit&id=' . $_REQUEST['cdef_id']); break; case 'item_edit': top_header(); item_edit(); bottom_footer(); break; case 'remove': cdef_remove(); header ('Location: cdef.php'); break; case 'edit': top_header(); cdef_edit(); bottom_footer(); break; default: top_header(); cdef(); bottom_footer(); break; } /* -------------------------- Global Form Functions -------------------------- */ function draw_cdef_preview($cdef_id) { ?>
cdef=
' . htmlspecialchars(db_fetch_cell('select name from cdef where id=' . $matches[1])) . ''; $cdef_array[$i] = $matches[1]; $i++; } } top_header(); print "
\n"; html_start_box('' . $cdef_actions{$_POST['drp_action']} . '', '60%', '', '3', 'center', ''); if (isset($cdef_array) && sizeof($cdef_array)) { if ($_POST['drp_action'] == '1') { /* delete */ print "

When you click \"Continue\", the folling CDEF(s) will be deleted.

\n"; $save_html = " "; }elseif ($_POST['drp_action'] == '2') { /* duplicate */ print "

When you click \"Continue\", the following CDEFs will be duplicated. You can optionally change the title format for the new CDEFs.

Title Format:
"; form_text_box("title_format", " (1)", "", "255", "30", "text"); print "

\n"; $save_html = " "; } }else{ print "You must select at least one CDEF.\n"; $save_html = ""; } print " $save_html \n"; html_end_box(); bottom_footer(); } /* -------------------------- CDEF Item Functions -------------------------- */ function item_movedown() { /* ================= input validation ================= */ input_validate_input_number(get_request_var_request('id')); input_validate_input_number(get_request_var_request('cdef_id')); /* ==================================================== */ move_item_down('cdef_items', $_REQUEST['id'], 'cdef_id=' . $_REQUEST['cdef_id']); } function item_moveup() { /* ================= input validation ================= */ input_validate_input_number(get_request_var_request('id')); input_validate_input_number(get_request_var_request('cdef_id')); /* ==================================================== */ move_item_up('cdef_items', $_REQUEST['id'], 'cdef_id=' . $_REQUEST['cdef_id']); } function item_remove() { /* ================= input validation ================= */ input_validate_input_number(get_request_var_request('id')); input_validate_input_number(get_request_var_request('cdef_id')); /* ==================================================== */ db_execute('delete from cdef_items where id=' . $_REQUEST['id']); } function item_edit() { global $cdef_item_types, $cdef_functions, $cdef_operators, $custom_data_source_types; /* ================= input validation ================= */ input_validate_input_number(get_request_var_request('id')); input_validate_input_number(get_request_var_request('cdef_id')); /* ==================================================== */ if (!empty($_REQUEST['id'])) { $cdef = db_fetch_row('select * from cdef_items where id=' . $_REQUEST['id']); $current_type = $cdef['type']; $values[$current_type] = $cdef['value']; } html_start_box('', '100%', '', '3', 'center', ''); draw_cdef_preview($_REQUEST['cdef_id']); html_end_box(); print "\n"; html_start_box('CDEF Items [edit: ' . htmlspecialchars(db_fetch_cell('SELECT name FROM cdef WHERE id=' . $_REQUEST['cdef_id'])) . ']', '100%', '', '3', 'center', ''); if (isset($_REQUEST['type_select'])) { $current_type = $_REQUEST['type_select']; }elseif (isset($cdef['type'])) { $current_type = $cdef['type']; }else{ $current_type = '1'; } form_alternate_row();?> CDEF Item Type
Choose what type of CDEF item this is. form_alternate_row();?> CDEF Item Value
Enter a value for this CDEF item. '" . htmlspecialchars(db_fetch_cell('select name from cdef where id=' . $_REQUEST['id'])) . "'?", htmlspecialchars('cdef.php'), htmlspecialchars('cdef.php?action=remove&id=' . $_REQUEST['id'])); bottom_footer(); exit; } if ((read_config_option('deletion_verification') == '') || (isset($_REQUEST['confirm']))) { db_execute('delete from cdef where id=' . $_REQUEST['id']); db_execute('delete from cdef_items where cdef_id=' . $_REQUEST['id']); } } function cdef_edit() { global $cdef_item_types, $fields_cdef_edit; /* ================= input validation ================= */ input_validate_input_number(get_request_var_request('id')); /* ==================================================== */ if (!empty($_REQUEST['id'])) { $cdef = db_fetch_row('select * from cdef where id=' . $_REQUEST['id']); $header_label = '[edit: ' . htmlspecialchars($cdef['name']) . ']'; }else{ $header_label = '[new]'; } html_start_box("CDEF's $header_label", '100%', '', '3', 'center', ''); draw_edit_form(array( 'config' => array(), 'fields' => inject_form_variables($fields_cdef_edit, (isset($cdef) ? $cdef : array())) )); html_end_box(); if (!empty($_REQUEST['id'])) { html_start_box('', '100%', '', '3', 'center', ''); draw_cdef_preview($_REQUEST['id']); html_end_box(); html_start_box('CDEF Items', '100%', '', '3', 'center', 'cdef.php?action=item_edit&cdef_id=' . $cdef['id']); print ""; DrawMatrixHeaderItem('Item', '', 1); DrawMatrixHeaderItem('Position', '', 1); DrawMatrixHeaderItem('Item Value', '', 2); print ''; $cdef_items = db_fetch_assoc('SELECT * FROM cdef_items WHERE cdef_id=' . $_REQUEST['id'] . ' ORDER BY sequence'); $i = 0; if (sizeof($cdef_items) > 0) { foreach ($cdef_items as $cdef_item) { form_alternate_row();$i++;?> '>Item # '>Move Down '>Move Up : '>Delete CDEF's", '100%', '', '3', 'center', 'cdef.php?action=edit'); ?>
Search: '> CDEFs:
'>
\n"; html_start_box('', '100%', '', '3', 'center', ''); $total_rows = db_fetch_cell("SELECT COUNT(cdef.id) FROM cdef $sql_where"); $cdef_list = db_fetch_assoc("SELECT cdef.id,cdef.name FROM cdef $sql_where ORDER BY " . get_request_var_request('sort_column') . ' ' . get_request_var_request('sort_direction') . ' LIMIT ' . (get_request_var_request('rows')*(get_request_var_request('page')-1)) . ',' . get_request_var_request('rows')); $nav = html_nav_bar('cdef.php?filter=' . get_request_var_request('filter'), MAX_DISPLAY_PAGES, get_request_var_request('page'), get_request_var_request('rows'), $total_rows, 2, 'CDEFs', 'page', 'main'); print $nav; $display_text = array( 'name' => array('CDEF Title', 'ASC')); html_header_sort_checkbox($display_text, get_request_var_request('sort_column'), get_request_var_request('sort_direction'), false); $i = 0; if (sizeof($cdef_list) > 0) { foreach ($cdef_list as $cdef) { form_alternate_row('line' . $cdef['id']); form_selectable_cell("" . (strlen(get_request_var_request('filter')) ? preg_replace('/(' . preg_quote(get_request_var_request('filter'), '/') . ')/i', "\\1", htmlspecialchars($cdef['name'])) : htmlspecialchars($cdef['name'])) . '', $cdef['id']); form_checkbox_cell($cdef['name'], $cdef['id']); form_end_row(); } print $nav; }else{ print "No CDEFs\n"; } html_end_box(false); /* draw the dropdown containing a list of available actions for this form */ draw_actions_dropdown($cdef_actions); print "\n"; } ?>