Minor - format code

fc4ee68c2b
pull/3559/head
Julio Montoya 5 years ago
parent 64e1983f6d
commit 138854be25
  1. 30
      plugin/cleandeletedfiles/admin.php
  2. 2
      plugin/cleandeletedfiles/config.php
  3. 1
      plugin/cleandeletedfiles/index.php
  4. 3
      plugin/cleandeletedfiles/plugin.php
  5. 4
      plugin/cleandeletedfiles/src/CleanDeletedFilesPlugin.php
  6. 6
      plugin/cleandeletedfiles/src/ajax.php

@ -6,9 +6,8 @@
* Plugin. * Plugin.
* *
* @author Jose Angel Ruiz * @author Jose Angel Ruiz
*
* @package chamilo.plugin.CleanDeletedFiles
*/ */
$cidReset = true; $cidReset = true;
require_once __DIR__.'/config.php'; require_once __DIR__.'/config.php';
@ -17,12 +16,11 @@ api_protect_admin_script();
/** @var \CleanDeletedFilesPlugin $plugin */ /** @var \CleanDeletedFilesPlugin $plugin */
$plugin = CleanDeletedFilesPlugin::create(); $plugin = CleanDeletedFilesPlugin::create();
$plugin_info = $plugin->get_info(); $plugin_info = $plugin->get_info();
$isPlatformAdmin = api_is_platform_admin(); $isPlatformAdmin = api_is_platform_admin();
if ($plugin->isEnabled() && $isPlatformAdmin) { if ($plugin->isEnabled() && $isPlatformAdmin) {
$htmlHeadXtra[] = '<script> $htmlHeadXtra[] = '<script>
$(document).ready(function() { $(function() {
$(".delete-file").click(function(e) { $(".delete-file").click(function(e) {
e.preventDefault(); e.preventDefault();
var path = $(this).prop("href").substr(7); var path = $(this).prop("href").substr(7);
@ -84,7 +82,8 @@ if ($plugin->isEnabled() && $isPlatformAdmin) {
"app/upload", "app/upload",
]; ];
function findDeletedFiles($pathRelative) { function findDeletedFiles($pathRelative)
{
global $sizePath; global $sizePath;
$pathAbsolute = api_get_path(SYS_PATH).$pathRelative; $pathAbsolute = api_get_path(SYS_PATH).$pathRelative;
$result = []; $result = [];
@ -92,9 +91,9 @@ if ($plugin->isEnabled() && $isPlatformAdmin) {
$dir = dir($pathAbsolute); $dir = dir($pathAbsolute);
while ($file = $dir->read()) { while ($file = $dir->read()) {
if (is_file($pathAbsolute.'/'.$file)) { if (is_file($pathAbsolute.'/'.$file)) {
$filesize = round(filesize($pathAbsolute.'/'.$file)/1024, 1); $filesize = round(filesize($pathAbsolute.'/'.$file) / 1024, 1);
$pos = strpos($file, "DELETED"); $pos = strpos($file, "DELETED");
if ($pos !== FALSE) { if ($pos !== false) {
$result[] = [ $result[] = [
'path_complete' => $pathAbsolute.'/'.$file, 'path_complete' => $pathAbsolute.'/'.$file,
'path_relative' => $pathRelative.'/'.$file, 'path_relative' => $pathRelative.'/'.$file,
@ -102,11 +101,14 @@ if ($plugin->isEnabled() && $isPlatformAdmin) {
]; ];
$sizePath += $filesize; $sizePath += $filesize;
} }
} else if ($file!='..' && $file!='.') { } else {
$result = array_merge($result, findDeletedFiles($pathRelative.'/'.$file)); if ($file != '..' && $file != '.') {
$result = array_merge($result, findDeletedFiles($pathRelative.'/'.$file));
}
} }
} }
} }
return $result; return $result;
} }
@ -122,7 +124,7 @@ if ($plugin->isEnabled() && $isPlatformAdmin) {
echo "<li>".$plugin->get_lang('FilesDeletedMark').": <strong>".count($filesDeletedList)."</strong>"; echo "<li>".$plugin->get_lang('FilesDeletedMark').": <strong>".count($filesDeletedList)."</strong>";
echo "<li>".$plugin->get_lang('FileDirSize').": "; echo "<li>".$plugin->get_lang('FileDirSize').": ";
if ($sizePath >= 1024) { if ($sizePath >= 1024) {
echo "<strong>".round($sizePath/1024,1)." Mb</strong>"; echo "<strong>".round($sizePath / 1024, 1)." Mb</strong>";
} else { } else {
echo "<strong>".$sizePath." Kb</strong>"; echo "<strong>".$sizePath." Kb</strong>";
} }
@ -133,7 +135,7 @@ if ($plugin->isEnabled() && $isPlatformAdmin) {
'<input type="checkbox" id="select_'.$i.'" class="select_all" />', '<input type="checkbox" id="select_'.$i.'" class="select_all" />',
false, false,
null, null,
['style' => 'text-align:center'] ['style' => 'text-align:center'],
], ],
[$plugin->get_lang('path_dir'), true], [$plugin->get_lang('path_dir'), true],
[$plugin->get_lang('size'), true, null, ['style' => 'min-width:85px']], [$plugin->get_lang('size'), true, null, ['style' => 'min-width:85px']],
@ -151,12 +153,12 @@ if ($plugin->isEnabled() && $isPlatformAdmin) {
); );
$row = [ $row = [
'<input type="checkbox" '<input type="checkbox"
class="checkbox-'.$i.' checkbox-item" class="checkbox-'.$i.' checkbox-item"
id="file://'.$value['path_complete'].'" />', id="file://'.$value['path_complete'].'" />',
$value['path_relative'], $value['path_relative'],
$value['size'].' '.($value['size'] >= 1024 ? 'Mb' : 'Kb'), $value['size'].' '.($value['size'] >= 1024 ? 'Mb' : 'Kb'),
$tools $tools,
]; ];
$data[] = $row; $data[] = $row;
} }
@ -178,7 +180,7 @@ if ($plugin->isEnabled() && $isPlatformAdmin) {
} }
if ($sizeTotal >= 1024) { if ($sizeTotal >= 1024) {
echo $plugin->get_lang('SizeTotalAllDir').": <strong>".round($sizeTotal/1024,1).' Mb</strong>'; echo $plugin->get_lang('SizeTotalAllDir').": <strong>".round($sizeTotal / 1024, 1).' Mb</strong>';
} else { } else {
echo $plugin->get_lang('SizeTotalAllDir').": <strong>".$sizeTotal.' Kb</strong>'; echo $plugin->get_lang('SizeTotalAllDir').": <strong>".$sizeTotal.' Kb</strong>';
} }

@ -6,7 +6,5 @@
* Config the plugin. * Config the plugin.
* *
* @author Jose Angel Ruiz * @author Jose Angel Ruiz
*
* @package chamilo.plugin.CleanDeletedFiles
*/ */
require_once __DIR__.'/../../main/inc/global.inc.php'; require_once __DIR__.'/../../main/inc/global.inc.php';

@ -1,4 +1,5 @@
<?php <?php
/* For license terms, see /license.txt */ /* For license terms, see /license.txt */
require_once 'config.php'; require_once 'config.php';

@ -6,10 +6,7 @@
* Plugin. * Plugin.
* *
* @author Jose Angel Ruiz * @author Jose Angel Ruiz
*
* @package chamilo.plugin.CleanDeletedFiles
*/ */
/* Plugin config */
require_once __DIR__.'/config.php'; require_once __DIR__.'/config.php';
$plugin_info = CleanDeletedFilesPlugin::create()->get_info(); $plugin_info = CleanDeletedFilesPlugin::create()->get_info();

@ -6,13 +6,11 @@
* Clean deleted files plugin. * Clean deleted files plugin.
* *
* @author Jose Angel Ruiz * @author Jose Angel Ruiz
*
* @package chamilo.plugin.CleanDeletedFiles
*/ */
class CleanDeletedFilesPlugin extends Plugin class CleanDeletedFilesPlugin extends Plugin
{ {
public $isAdminPlugin = true; public $isAdminPlugin = true;
/** /**
* Class constructor. * Class constructor.
*/ */

@ -17,7 +17,7 @@ switch ($action) {
case 'delete-file': case 'delete-file':
$path = isset($_REQUEST['path']) ? $_REQUEST['path'] : null; $path = isset($_REQUEST['path']) ? $_REQUEST['path'] : null;
if (empty($path)) { if (empty($path)) {
echo json_encode(["status" => "false", "message"=>$plugin->get_lang('ErrorEmptyPath')]); echo json_encode(["status" => "false", "message" => $plugin->get_lang('ErrorEmptyPath')]);
exit; exit;
} }
@ -25,13 +25,13 @@ switch ($action) {
Display::addFlash($plugin->get_lang("DeletedSuccess"), 'success'); Display::addFlash($plugin->get_lang("DeletedSuccess"), 'success');
echo json_encode(["status" => "true"]); echo json_encode(["status" => "true"]);
} else { } else {
echo json_encode(["status" => "false", "message"=>$plugin->get_lang('ErrorDeleteFile')]); echo json_encode(["status" => "false", "message" => $plugin->get_lang('ErrorDeleteFile')]);
} }
break; break;
case 'delete-files-list': case 'delete-files-list':
$list = isset($_REQUEST['list']) ? $_REQUEST['list'] : []; $list = isset($_REQUEST['list']) ? $_REQUEST['list'] : [];
if (empty($list)) { if (empty($list)) {
echo json_encode(["status" => "false", "message"=>$plugin->get_lang('ErrorEmptyPath')]); echo json_encode(["status" => "false", "message" => $plugin->get_lang('ErrorEmptyPath')]);
exit; exit;
} }

Loading…
Cancel
Save