Remove unused functions, rename function

- Removed: dirsize, get_levels, create_link_file
- Renamed: LpItem::update_in_bdd to LpItem::update
pull/2487/head
jmontoyaa 7 years ago
parent 43826ff17b
commit 575e3b68c0
  1. 24
      main/inc/lib/fileManage.lib.php
  2. 41
      main/inc/lib/fileUpload.lib.php
  3. 6
      main/inc/lib/lp_item.lib.php
  4. 2
      main/lp/learnpath.class.php

@ -314,27 +314,3 @@ function getextension($filename)
$bouts = explode('.', $filename);
return array(array_pop($bouts), implode('.', $bouts));
}
/**
* Calculation size of a directory
*
* @returns integer size
* @param string $root path of dir to measure
* @param boolean $recursive if true , include subdirectory in total
*/
function dirsize($root, $recursive = true)
{
$dir = @opendir($root);
$size = 0;
while ($file = @readdir($dir)) {
if (!in_array($file, array('.', '..'))) {
if (is_dir($root.'/'.$file)) {
$size += $recursive ? dirsize($root.'/'.$file) : 0;
} else {
$size += @filesize($root.'/'.$file);
}
}
}
@closedir($dir);
return $size;
}

@ -1373,22 +1373,6 @@ function item_property_update_on_folder($_course, $path, $user_id)
}
}
/**
* Returns the directory depth of the file.
*
* @author Olivier Cauberghe <olivier.cauberghe@ugent.be>
* @param path+filename eg: /main/document/document.php
* @return The directory depth
*/
function get_levels($filename)
{
$levels = explode('/', $filename);
if (empty($levels[count($levels) - 1])) {
unset($levels[count($levels) - 1]);
}
return count($levels);
}
/**
* Adds file to document table in database
* deprecated: use file_set_default_settings instead
@ -1759,31 +1743,6 @@ function replace_img_path_in_html_file($original_img_path, $new_img_path, $html_
}
}
/**
* Creates a file containing an html redirection to a given url
*
* @author Hugues Peeters <hugues.peeters@claroline.net>
* @param string $file_path
* @param string $url
* @return void
*/
function create_link_file($file_path, $url)
{
$file_content = '<html>'
.'<head>'
.'<meta http-equiv="refresh" content="1;url='.$url.'">'
.'</head>'
.'<body>'
.'</body>'
.'</html>';
if (file_exists($file_path)) {
if (!($fp = fopen($file_path, 'w'))) {
return false;
}
return fwrite($fp, $file_content);
}
}
/**
* Checks the extension of a file, if it's .htm or .html
* we use search_img_from_html to get all image paths in the file

@ -80,11 +80,11 @@ class LpItem
/**
* Update in database
*/
public function update_in_bdd()
public function update()
{
$item_view_table = Database::get_course_table(TABLE_LP_ITEM);
$table = Database::get_course_table(TABLE_LP_ITEM);
if ($this->c_id > 0 && $this->id > 0) {
$sql = "UPDATE $item_view_table SET
$sql = "UPDATE $table SET
lp_id = '".intval($this->lp_id)."' ,
item_type = '".Database::escape_string($this->item_type)."' ,
ref = '".Database::escape_string($this->ref)."' ,

@ -9538,7 +9538,7 @@ class learnpath
$tmp_obj_exercice = new Exercise($course_id);
$tmp_obj_exercice->read($tmp_obj_lp_item->path);
$tmp_obj_lp_item->max_score = $tmp_obj_exercice->get_max_score();
$tmp_obj_lp_item->update_in_bdd();
$tmp_obj_lp_item->update();
$item['max_score'] = $tmp_obj_lp_item->max_score;
$return .= '<td>';

Loading…
Cancel
Save