Skip to content

Commit 744021d

Browse files
committed
QA: Adding more form confirmation API calls
* Adding 5 more. Which means 10 to go.
1 parent a2c9747 commit 744021d

File tree

6 files changed

+279
-296
lines changed

6 files changed

+279
-296
lines changed

aggregate_templates.php

Lines changed: 35 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
include_once('./lib/api_aggregate.php');
2727
include_once('./lib/data_query.php');
2828

29-
$aggregate_actions = array(
29+
$actions = array(
3030
1 => __('Delete')
3131
);
3232

@@ -283,7 +283,7 @@ function aggregate_get_graph_items($table, $id) {
283283
* aggregate_form_actions - the action function
284284
*/
285285
function aggregate_form_actions() {
286-
global $aggregate_actions, $config;
286+
global $actions, $config;
287287

288288
/* ================= input validation ================= */
289289
get_filter_request_var('drp_action');
@@ -300,67 +300,48 @@ function aggregate_form_actions() {
300300
db_execute('DELETE FROM aggregate_graph_templates_graph WHERE ' . array_to_sql_or($selected_items, 'aggregate_template_id'));
301301
db_execute("UPDATE aggregate_graphs SET aggregate_template_id=0, template_propogation='' WHERE " . array_to_sql_or($selected_items, 'aggregate_template_id'));
302302
}
303-
} else {
304303
}
305304

306305
header('Location: aggregate_templates.php');
307306

308307
exit;
309-
}
310-
311-
/* setup some variables */
312-
$aggregate_list = '';
313-
$i = 0;
314-
315-
/* loop through each of the color templates selected on the previous page and get more info about them */
316-
foreach ($_POST as $var => $val) {
317-
if (preg_match('/^chk_([0-9]+)$/', $var, $matches)) {
318-
/* ================= input validation ================= */
319-
input_validate_input_number($matches[1], 'chk[1]');
320-
/* ==================================================== */
321-
$aggregate_list .= '<li>' . html_escape(db_fetch_cell_prepared('SELECT name FROM aggregate_graph_templates WHERE id = ?', array($matches[1]))) . '</li>';
322-
$aggregate_array[] = $matches[1];
323-
}
324-
}
325-
326-
top_header();
327-
328-
form_start('aggregate_templates.php');
329-
330-
html_start_box($aggregate_actions[get_nfilter_request_var('drp_action')], '60%', '', '3', 'center', '');
331-
332-
if (isset($aggregate_array) && cacti_sizeof($aggregate_array)) {
333-
if (get_nfilter_request_var('drp_action') == '1') { /* delete */
334-
print "<tr>
335-
<td class='textArea'>
336-
<p>" . __('Click \'Continue\' to Delete the following Aggregate Graph Template(s).') . "</p>
337-
<div class='itemlist'><ul>$aggregate_list</ul></div>
338-
</td>
339-
</tr>\n";
340-
341-
$save_html = "<input type='button' class='ui-button ui-corner-all ui-widget' value='" . __esc('Cancel') . "' onClick='cactiReturnTo()'>&nbsp;<input type='submit' class='ui-button ui-corner-all ui-widget' value='" . __esc('Continue') . "' title='" . __esc('Delete Color Template(s)') . "'>";
342-
}
343308
} else {
344-
raise_message(40);
345-
header('Location: aggregate_templates.php');
309+
$ilist = '';
310+
$iarray = array();
346311

347-
exit;
348-
}
312+
/* loop through each of the color templates selected on the previous page and get more info about them */
313+
foreach ($_POST as $var => $val) {
314+
if (preg_match('/^chk_([0-9]+)$/', $var, $matches)) {
315+
/* ================= input validation ================= */
316+
input_validate_input_number($matches[1], 'chk[1]');
317+
/* ==================================================== */
349318

350-
print "<tr>
351-
<td class='saveRow'>
352-
<input type='hidden' name='action' value='actions'>
353-
<input type='hidden' name='selected_items' value='" . (isset($aggregate_array) ? serialize($aggregate_array) : '') . "'>
354-
<input type='hidden' name='drp_action' value='" . html_escape(get_nfilter_request_var('drp_action')) . "'>
355-
$save_html
356-
</td>
357-
</tr>\n";
319+
$ilist .= '<li>' . html_escape(db_fetch_cell_prepared('SELECT name FROM aggregate_graph_templates WHERE id = ?', array($matches[1]))) . '</li>';
358320

359-
html_end_box();
321+
$iarray[] = $matches[1];
322+
}
323+
}
360324

361-
form_end();
325+
$form_data = array(
326+
'general' => array(
327+
'page' => 'aggregate_templates.php',
328+
'actions' => $actions,
329+
'optvar' => 'drp_action',
330+
'item_array' => $iarray,
331+
'item_list' => $ilist
332+
),
333+
'options' => array(
334+
1 => array(
335+
'smessage' => __('Click \'Continue\' to Delete the following Aggregate Graph Template.'),
336+
'pmessage' => __('Click \'Continue\' to Delete following Aggregate Graph Templates.'),
337+
'scont' => __('Delete Aggregate Graph Template'),
338+
'pcont' => __('Delete Aggregate Graph Templates')
339+
)
340+
)
341+
);
362342

363-
bottom_footer();
343+
form_continue_confirmation($form_data);
344+
}
364345
}
365346

366347
/**
@@ -559,7 +540,7 @@ function changeTotalsType() {
559540
* aggregate_template
560541
*/
561542
function aggregate_template() {
562-
global $aggregate_actions, $item_rows, $config;
543+
global $actions, $item_rows, $config;
563544

564545
/* ================= input validation and session storage ================= */
565546
$filters = array(
@@ -738,7 +719,7 @@ function aggregate_template() {
738719
}
739720

740721
/* draw the dropdown containing a list of available actions for this form */
741-
draw_actions_dropdown($aggregate_actions);
722+
draw_actions_dropdown($actions);
742723

743724
form_end();
744725

color_templates.php

Lines changed: 61 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
include_once('./include/auth.php');
2626

27-
$aggregate_actions = array(
27+
$actions = array(
2828
1 => __('Delete'),
2929
2 => __('Duplicate'),
3030
3 => __('Sync Aggregates')
@@ -256,7 +256,7 @@ function form_save() {
256256
* form_actions the action function
257257
*/
258258
function form_actions() {
259-
global $aggregate_actions, $config;
259+
global $actions, $config;
260260
include_once(CACTI_PATH_LIBRARY . '/api_aggregate.php');
261261

262262
/* ================= input validation ================= */
@@ -285,88 +285,67 @@ function form_actions() {
285285
header('Location: color_templates.php');
286286

287287
exit;
288-
}
289-
290-
/* setup some variables */
291-
$color_list = '';
292-
$i = 0;
293-
294-
/* loop through each of the color templates selected on the previous page and get more info about them */
295-
foreach ($_POST as $var => $val) {
296-
if (preg_match('/^chk_([0-9]+)$/', $var, $matches)) {
297-
/* ================= input validation ================= */
298-
input_validate_input_number($matches[1], 'chk[1]');
299-
/* ==================================================== */
300-
301-
$name = db_fetch_cell_prepared('SELECT name
302-
FROM color_templates
303-
WHERE color_template_id = ?',
304-
array($matches[1]));
305-
306-
$color_list .= '<li>' . html_escape($name) . '</li>';
307-
$color_array[] = $matches[1];
288+
} else {
289+
$ilist = '';
290+
$iarray = array();
291+
292+
/* loop through each of the color templates selected on the previous page and get more info about them */
293+
foreach ($_POST as $var => $val) {
294+
if (preg_match('/^chk_([0-9]+)$/', $var, $matches)) {
295+
/* ================= input validation ================= */
296+
input_validate_input_number($matches[1], 'chk[1]');
297+
/* ==================================================== */
298+
299+
$name = db_fetch_cell_prepared('SELECT name
300+
FROM color_templates
301+
WHERE color_template_id = ?',
302+
array($matches[1]));
303+
304+
$ilist .= '<li>' . html_escape($name) . '</li>';
305+
$iarray[] = $matches[1];
306+
}
308307
}
309-
}
310-
311-
top_header();
312308

313-
form_start('color_templates.php');
314-
315-
html_start_box($aggregate_actions[get_nfilter_request_var('drp_action')], '60%', '', '3', 'center', '');
316-
317-
if (isset($color_array) && cacti_sizeof($color_array)) {
318-
if (get_request_var('drp_action') == '1') { /* delete */
319-
print "<tr>
320-
<td class='textArea'>
321-
<p>" . __n('Click \'Continue\' to delete the following Color Template', 'Click \'Continue\' to delete following Color Templates', cacti_sizeof($color_array)) . "</p>
322-
<div class='itemlist'><ul>$color_list</ul></div>
323-
</td>
324-
</tr>";
325-
326-
$save_html = "<input type='button' class='ui-button ui-corner-all ui-widget' value='" . __esc('Cancel') . "' onClick='cactiReturnTo()'>&nbsp;<input type='submit' class='ui-button ui-corner-all ui-widget' value='" . __esc('Continue') . "' title='" . __n('Delete Color Template', 'Delete Color Templates', cacti_sizeof($color_array)) . "'>";
327-
} elseif (get_request_var('drp_action') == '2') { // duplicate
328-
print "<tr>
329-
<td class='textArea'>
330-
<p>" . __n('Click \'Continue\' to duplicate the following Color Template. You can optionally change the title format for the new color template.', 'Click \'Continue\' to duplicate following Color Templates. You can optionally change the title format for the new color templates.', cacti_sizeof($color_array)) . "</p>
331-
<div class='itemlist'><ul>$color_list</ul></div>
332-
<p>" . __('Title Format:') . '<br>';
333-
form_text_box('title_format', '<template_title> (1)', '', '255', '30', 'text');
334-
print '</p>
335-
</td>
336-
</tr>';
337-
338-
$save_html = "<input type='button' class='ui-button ui-corner-all ui-widget' value='" . __esc('Cancel') . "' onClick='cactiReturnTo()'>&nbsp;<input type='submit' class='ui-button ui-corner-all ui-widget' value='" . __esc('Continue') . "' title='" . __n('Duplicate Color Template', 'Duplicate Color Templates', cacti_sizeof($color_array)) . "'>";
339-
} elseif (get_request_var('drp_action') == '3') { // sync
340-
print "<tr>
341-
<td class='textArea'>
342-
<p>" . __n('Click \'Continue\' to Synchronize all Aggregate Graphs with the selected Color Template.', 'Click \'Continue\' to Synchronize all Aggregate Graphs with the selected Color Templates.', cacti_sizeof($color_array)) . "</p>
343-
<div class='itemlist'><ul>$color_list</ul></div></p>
344-
</td>
345-
</tr>";
346-
347-
$save_html = "<input type='button' class='ui-button ui-corner-all ui-widget' value='" . __esc('Cancel') . "' onClick='cactiReturnTo()'>&nbsp;<input type='submit' class='ui-button ui-corner-all ui-widget' value='" . __esc('Continue') . "' title='" . __n('Synchronize Color Template', 'Synchronize Color Templates', cacti_sizeof($color_array)) . "'>";
348-
}
349-
} else {
350-
raise_message(40);
351-
header('Location: color_templates.php');
309+
$form_data = array(
310+
'general' => array(
311+
'page' => 'color_templates.php',
312+
'actions' => $actions,
313+
'optvar' => 'drp_action',
314+
'item_array' => $iarray,
315+
'item_list' => $ilist
316+
),
317+
'options' => array(
318+
1 => array(
319+
'smessage' => __('Click \'Continue\' to Delete the following Color Template.'),
320+
'pmessage' => __('Click \'Continue\' to Delete following Color Templates.'),
321+
'scont' => __('Delete Color Template'),
322+
'pcont' => __('Delete Color Templates')
323+
),
324+
2 => array(
325+
'smessage' => __('Click \'Continue\' to Duplicate the following Color Template.'),
326+
'pmessage' => __('Click \'Continue\' to Duplicate following Color Templates.'),
327+
'scont' => __('Duplicate Color Template'),
328+
'pcont' => __('Duplicate Color Templates'),
329+
'extra' => array(
330+
'title_format' => array(
331+
'method' => 'textbox',
332+
'title' => __('Title Format:'),
333+
'default' => '<template_titel> (1)',
334+
'width' => 25
335+
)
336+
)
337+
),
338+
3 => array(
339+
'smessage' => __('Click \'Continue\' to Syncronize the following Color Template to its Aggregates.'),
340+
'pmessage' => __('Click \'Continue\' to Syncronize the following Color Templates to its Aggregates.'),
341+
'scont' => __('Synchronize Color Template'),
342+
'pcont' => __('Synchronize Color Templates')
343+
),
344+
)
345+
);
352346

353-
exit;
347+
form_continue_confirmation($form_data);
354348
}
355-
356-
print "<tr>
357-
<td class='saveRow'>
358-
<input type='hidden' name='action' value='actions'>
359-
<input type='hidden' name='selected_items' value='" . (isset($color_array) ? serialize($color_array) : '') . "'>
360-
<input type='hidden' name='drp_action' value='" . get_request_var('drp_action') . "'>
361-
$save_html
362-
</td>
363-
</tr>\n";
364-
365-
html_end_box();
366-
367-
form_end();
368-
369-
bottom_footer();
370349
}
371350

372351
function color_templates_item_dnd() {
@@ -790,7 +769,7 @@ function sync_color_templates($color_template) {
790769
* color_template maintain color templates
791770
*/
792771
function color_template() {
793-
global $aggregate_actions, $item_rows, $config;
772+
global $actions, $item_rows, $config;
794773
include_once(CACTI_PATH_LIBRARY . '/api_aggregate.php');
795774

796775
/* ================= input validation and session storage ================= */
@@ -981,7 +960,7 @@ function color_template() {
981960
}
982961

983962
/* draw the dropdown containing a list of available actions for this form */
984-
draw_actions_dropdown($aggregate_actions);
963+
draw_actions_dropdown($actions);
985964

986965
form_end();
987966

0 commit comments

Comments
 (0)