Add feature of upload background to visual consoles. Tiquet: #2945
This commit is contained in:
parent
13b480ec92
commit
cb6a8c023a
|
@ -51,11 +51,11 @@ $pure = get_parameter('pure', 0);
|
|||
switch ($action) {
|
||||
case 'new':
|
||||
if (!defined('METACONSOLE')) {
|
||||
echo "<form method='post' action='index.php?sec=reporting&sec2=godmode/reporting/visual_console_builder&tab=" . $activeTab . "'>";
|
||||
echo "<form method='post' action='index.php?sec=reporting&sec2=godmode/reporting/visual_console_builder&tab=" . $activeTab . "' enctype='multipart/form-data'>";
|
||||
html_print_input_hidden('action', 'save');
|
||||
}
|
||||
else {
|
||||
echo '<form action="index.php?operation=edit_visualmap&sec=screen&sec2=screens/screens&action=visualmap&pure=' . $pure . '" method="post">';
|
||||
echo '<form action="index.php?operation=edit_visualmap&sec=screen&sec2=screens/screens&action=visualmap&pure=' . $pure . '" method="post" enctype="multipart/form-data">';
|
||||
html_print_input_hidden('action2', 'save');
|
||||
}
|
||||
|
||||
|
@ -63,22 +63,22 @@ switch ($action) {
|
|||
case 'update':
|
||||
case 'save':
|
||||
if (!defined('METACONSOLE')) {
|
||||
echo "<form method='post' action='index.php?sec=reporting&sec2=godmode/reporting/visual_console_builder&tab=" . $activeTab . "&id_visual_console=" . $idVisualConsole . "'>";
|
||||
echo "<form method='post' action='index.php?sec=reporting&sec2=godmode/reporting/visual_console_builder&tab=" . $activeTab . "&id_visual_console=" . $idVisualConsole . "' enctype='multipart/form-data'>";
|
||||
html_print_input_hidden('action', 'update');
|
||||
}
|
||||
else {
|
||||
//echo '<form action="index.php?operation=edit_visualmap&sec=screen&sec2=screens/screens&action=visualmap&pure=' . $pure . '" method="post">';
|
||||
echo "<form action='index.php?sec=screen&sec2=screens/screens&tab=" . $activeTab . "&id_visual_console=" . $idVisualConsole . "&id_visualmap=" . $idVisualConsole . "&action=visualmap' method='post' >";
|
||||
echo "<form action='index.php?sec=screen&sec2=screens/screens&tab=" . $activeTab . "&id_visual_console=" . $idVisualConsole . "&id_visualmap=" . $idVisualConsole . "&action=visualmap' method='post' enctype='multipart/form-data'>";
|
||||
html_print_input_hidden('action2', 'update');
|
||||
}
|
||||
break;
|
||||
case 'edit':
|
||||
if (!defined('METACONSOLE')) {
|
||||
echo "<form method='post' action='index.php?sec=reporting&sec2=godmode/reporting/visual_console_builder&tab=" . $activeTab . "&id_visual_console=" . $idVisualConsole . "'>";
|
||||
echo "<form method='post' action='index.php?sec=reporting&sec2=godmode/reporting/visual_console_builder&tab=" . $activeTab . "&id_visual_console=" . $idVisualConsole . "' enctype='multipart/form-data'>";
|
||||
html_print_input_hidden('action', 'update');
|
||||
}
|
||||
else {
|
||||
echo "<form action='index.php?operation=edit_visualmap&sec=screen&sec2=screens/screens&tab=" . $activeTab . "&id_visual_console=" . $idVisualConsole . "&action=visualmap' method='post' >";
|
||||
echo "<form action='index.php?operation=edit_visualmap&sec=screen&sec2=screens/screens&tab=" . $activeTab . "&id_visual_console=" . $idVisualConsole . "&action=visualmap' method='post' enctype='multipart/form-data' >";
|
||||
html_print_input_hidden('action2', 'update');
|
||||
}
|
||||
break;
|
||||
|
@ -121,6 +121,8 @@ $backgrounds_list = array_merge($backgrounds_list,
|
|||
$table->data[2][0] = __('Background');
|
||||
$table->data[2][1] = html_print_select($backgrounds_list, 'background',
|
||||
$background, '', '', 0, true);
|
||||
$table->data[3][0] = __('Background image');
|
||||
$table->data[3][1] = html_print_input_file('background_image',true);
|
||||
if ($action == 'new') {
|
||||
$textButtonSubmit = __('Save');
|
||||
$classButtonSubmit = 'sub wand';
|
||||
|
|
|
@ -129,8 +129,71 @@ switch ($activeTab) {
|
|||
'name' => $visualConsoleName,
|
||||
'id_group' => $idGroup,
|
||||
'background' => $background
|
||||
);
|
||||
);
|
||||
|
||||
$error = $_FILES['background_image']['error'];
|
||||
$upload_file = true;
|
||||
$uploadOK = true;
|
||||
switch ($error) {
|
||||
case UPLOAD_ERR_OK:
|
||||
$tmpName = $_FILES['background_image']['tmp_name'];
|
||||
$pathname = $config['homedir'] . '/images/console/background/';
|
||||
$nameImage = str_replace(' ','_',$_FILES["background_image"]["name"]);
|
||||
$target_file = $pathname . basename($nameImage);
|
||||
$imageFileType = strtolower( pathinfo($target_file,PATHINFO_EXTENSION));
|
||||
|
||||
$check = getimagesize($_FILES["background_image"]["tmp_name"]);
|
||||
if($check !== false) {
|
||||
$uploadOK = 1;
|
||||
} else {
|
||||
$uploadOK = false;
|
||||
$error_message = __("This file isn't image");
|
||||
$statusProcessInDB = array('flag' => false, 'message' => ui_print_error_message(__("This file isn't image."), '', true));
|
||||
}
|
||||
if (file_exists($target_file)) {
|
||||
$uploadOK = false;
|
||||
$error_message = __("File already are exists.");
|
||||
$statusProcessInDB = array('flag' => false, 'message' => ui_print_error_message(__('File already are exists.'), '', true));
|
||||
}
|
||||
|
||||
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
|
||||
&& $imageFileType != "gif" ) {
|
||||
$uploadOK = false;
|
||||
$error_message = __("The file have not image extension.");
|
||||
$statusProcessInDB = array('flag' => false, 'message' => ui_print_error_message(__('The file have not image extension.'), '', true));
|
||||
}
|
||||
|
||||
if ($uploadOK == 1) {
|
||||
if (move_uploaded_file($_FILES["background_image"]["tmp_name"], $target_file)) {
|
||||
$background = $_FILES["background_image"]["name"];
|
||||
$values['background'] = $background;
|
||||
$error2 = chmod($target_file, 0644);
|
||||
$uploadOK = $error2;
|
||||
} else {
|
||||
$uploadOK = false;
|
||||
$error_message = __("Problems with move file to target.");
|
||||
$statusProcessInDB = array('flag' => false, 'message' => ui_print_error_message(__('Problems with move file to target.'), '', true));
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
case UPLOAD_ERR_INI_SIZE:
|
||||
$uploadOK = false;
|
||||
$statusProcessInDB = array('flag' => false, 'message' => ui_print_error_message(__('Problems with move file to target.'), '', true));
|
||||
case UPLOAD_ERR_PARTIAL:
|
||||
$uploadOK = false;
|
||||
$statusProcessInDB = array('flag' => false, 'message' => ui_print_error_message(__('Problems with move file to target.'), '', true));
|
||||
break;
|
||||
case UPLOAD_ERR_NO_FILE:
|
||||
$upload_file = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( $upload_file && !$uploadOK){
|
||||
db_pandora_audit( "Visual console builder", $error_message);
|
||||
break;
|
||||
}
|
||||
|
||||
// If the background is changed the size is reseted
|
||||
$background_now = $visualConsole['background'];
|
||||
if ($background_now != $background && $background) {
|
||||
|
|
Loading…
Reference in New Issue