fixed error update manager delete files

Former-commit-id: 88b915f9278eba5949c867ae514a104ce796aec1
This commit is contained in:
Daniel Barbero 2019-03-15 12:19:02 +01:00
parent 916d11c625
commit d5108efb0d
4 changed files with 56 additions and 71 deletions

View File

@ -633,6 +633,7 @@ if ($delete_desired_files === true) {
// Initialize result.
$result = [];
$result['status_list'] = [];
// Flag exist folder "deleted".
$exist_deleted = true;
@ -658,8 +659,8 @@ if ($delete_desired_files === true) {
}
$res['type'] = 'd';
$res['route'] = $url_to_delete;
array_push($result, $res);
$res['path'] = $url_to_delete;
array_push($result['status_list'], $res);
}
// Check isset delete_files.txt.
@ -673,34 +674,34 @@ if ($delete_desired_files === true) {
$url_to_delete = $config['homedir'].'/'.$file_to_delete;
// Check is dir or file or not exists.
if (is_dir($url_to_delete) === true) {
$result = rmdir_recursive(
$rmdir_recursive = rmdir_recursive(
$url_to_delete,
$result
$result['status_list']
);
array_push(
$result['status_list'],
$rmdir_recursive
);
} else if (file_exists($url_to_delete) === true) {
$unlink = unlink($url_to_delete);
$res = [];
if ($unlink === true) {
$res['status'] = 0;
} else {
$res['status'] = 1;
}
$res['status'] = ($unlink === true) ? 0 : 1;
$res['type'] = 'f';
$res['route'] = $url_to_delete;
array_push($result, $res);
$res['path'] = $url_to_delete;
array_push($result['status_list'], $res);
} else {
$res = [];
$res['status'] = 2;
$res['route'] = $url_to_delete;
array_push($result, $res);
$res['path'] = $url_to_delete;
array_push($result['status_list'], $res);
}
}
} else {
$res = [];
$res['status'] = 3;
$res['route'] = $url_to_delete;
array_push($result, $res);
$res['path'] = $url_to_delete;
array_push($result['status_list'], $res);
}
// Close file.
@ -715,25 +716,20 @@ if ($delete_desired_files === true) {
);
$res = [];
if ($res_rename !== true) {
$res['status'] = 6;
} else {
$res['status'] = 7;
}
$res['status'] = ($res_rename === true) ? 7 : 6;
$res['type'] = 'f';
$res['route'] = $route_move;
array_push($result, $res);
$res['path'] = $route_move;
array_push($result['status_list'], $res);
} else {
if ($exist_deleted === true) {
$res = [];
$res['status'] = -1;
array_push($result, $res);
array_push($result['status_list'], $res);
}
}
// Translate diccionary neccesary.
$result['translate'] = [
// Translation diccionary neccesary.
$result['translation'] = [
'title' => __('Delete files'),
'not_file' => __('The oum has no files to remove'),
'not_found' => __('Not found'),

View File

@ -1028,7 +1028,7 @@ function update_manger_set_deleted_message($message_id)
* @return array Return result array with status 0 valid or 1 false and
* type 'f' file and 'd' dir and route path file or directory.
*/
function rmdir_recursive(string $dir, array $result)
function rmdir_recursive(string $dir, array &$result)
{
foreach (scandir($dir) as $file) {
if ('.' === $file || '..' === $file) {
@ -1036,32 +1036,22 @@ function rmdir_recursive(string $dir, array $result)
}
if (is_dir($dir.'/'.$file) === true) {
rmdir_recursive($dir.'/'.$file, $result, $i);
rmdir_recursive($dir.'/'.$file, $result);
} else {
$unlink = unlink($dir.'/'.$file);
$res = [];
if ($unlink === true) {
$res['status'] = 0;
} else {
$res['status'] = 1;
}
$res['status'] = ($unlink === true) ? 0 : 1;
$res['type'] = 'f';
$res['route'] = $dir.'/'.$file;
$res['path'] = $dir.'/'.$file;
array_push($result, $res);
}
}
$rmdir = rmdir($dir);
$res = [];
if ($rmdir === true) {
$res['status'] = 0;
} else {
$res['status'] = 1;
}
$res['status'] = ($rmdir === true) ? 0 : 1;
$res['type'] = 'd';
$res['route'] = $dir;
$res['path'] = $dir;
array_push($result, $res);
return $result;

View File

@ -2317,78 +2317,77 @@ function delete_desired_files(homeurl) {
url: home_url + "ajax.php",
dataType: "json",
success: function(data) {
var translate = data.translate;
var translation = data.translation;
// Print the deleted files.
// Print title
// Print title.
$("#log_zone").append(
"</br></br><span class='log_zone_line log_zone_line_bolder';>" +
translate.title +
"</br></br><span class='log_zone_line bolder';>" +
translation.title +
": </span></br></br>"
);
$.each(data, function(key, value) {
$.each(data.status_list, function(key, value) {
var log_zone_line_class = "log_zone_line ";
var msg = "";
switch (value.status) {
case -1:
//Not exits file.
msg = translate.not_file;
msg = translation.not_file;
break;
case 0:
//File or directory deleted successfully.
if (value.type === "f") {
log_zone_line_class += "";
} else {
log_zone_line_class += "log_zone_line_bolder";
log_zone_line_class += "bolder";
}
msg = value.route;
msg = value.path;
break;
case 1:
//Problem delete file or directory.
if (value.type === "f") {
log_zone_line_class += "log_zone_line_error";
} else {
log_zone_line_class += "log_zone_line_error log_zone_line_bolder";
log_zone_line_class += "log_zone_line_error bolder";
}
msg = value.route + " ( " + translate.not_deleted + " ) ";
msg = value.path + " ( " + translation.not_deleted + " ) ";
break;
case 2:
//Not found file or directory.
if (value.type === "f") {
log_zone_line_class += "log_zone_line_error";
} else {
log_zone_line_class += "log_zone_line_error log_zone_line_bolder";
log_zone_line_class += "log_zone_line_error bolder";
}
msg = value.route + " ( " + translate.not_found + " ) ";
msg = value.path + " ( " + translation.not_found + " ) ";
break;
case 3:
//Don`t read file deleet_files.txt.
log_zone_line_class += "log_zone_line_error log_zone_line_bolder";
msg = translate.not_read;
log_zone_line_class += "log_zone_line_error bolder";
msg = translation.not_read;
break;
case 4:
//"deleted" folder could not be created.
log_zone_line_class += "log_zone_line_error log_zone_line_bolder";
msg = value.route + " ( " + translate.folder_deleted_f + " ) ";
log_zone_line_class += "log_zone_line_error bolder";
msg = value.path + " ( " + translation.folder_deleted_f + " ) ";
break;
case 5:
//"deleted" folder was created.
log_zone_line_class += "log_zone_line_bolder";
msg = translate.folder_deleted_t;
log_zone_line_class += "bolder";
msg = translation.folder_deleted_t;
break;
case 6:
//The "delete files" could not be the "delete" folder.
log_zone_line_class += "log_zone_line_error log_zone_line_bolder";
msg = value.route + " ( " + translate.move_file_f + " ) ";
log_zone_line_class += "log_zone_line_error bolder";
msg = value.path + " ( " + translation.move_file_f + " ) ";
break;
case 7:
//The "delete files" is moved to the "delete" folder.
log_zone_line_class += "log_zone_line_bolder";
msg = translate.move_file_d;
log_zone_line_class += "bolder";
msg = translation.move_file_d;
break;
case "translate":
default:
// It can not come without state.
break;

View File

@ -3925,14 +3925,14 @@ span.log_zone_line {
}
span.log_zone_line_error {
color: red;
}
span.log_zone_line_bolder {
font-weight: bolder;
color: #fc4444;
}
/* global */
.bolder {
font-weight: bolder;
}
.readonly {
background-color: #dedede !important;
}