Not let the user override files and count the file size just once (the last update) - refs BT#7644

1.9.x
Francis Gonzales 11 years ago
parent a5f40a29c8
commit 84285bba7c
  1. 2
      main/inc/ajax/document.ajax.php
  2. 19
      main/inc/lib/document.lib.php

@ -33,7 +33,7 @@ switch($action) {
$file['name'],
null,
0,
'overwrite',
null,
false,
false
);

@ -2579,7 +2579,7 @@ class DocumentManager
$session_condition = " AND props.id_session='" . $session_id . "' ";
}
$sql = "SELECT SUM(size) FROM " . $TABLE_ITEMPROPERTY . " AS props, " . $TABLE_DOCUMENT . " AS docs
$sql = "SELECT coalesce(docs.size, 0), docs.path FROM " . $TABLE_ITEMPROPERTY . " AS props, " . $TABLE_DOCUMENT . " AS docs
WHERE props.c_id = $course_id AND
docs.c_id = $course_id AND
docs.id = props.ref AND
@ -2587,15 +2587,18 @@ class DocumentManager
props.visibility <> 2
$group_condition
$session_condition
ORDER BY docs.id
";
$result = Database::query($sql);
if ($result && Database::num_rows($result) != 0) {
$row = Database::fetch_row($result);
return $row[0];
} else {
return 0;
}
//Not count the same file more than once
//if there is more than once just take the last
$docsSize = array();
while ($row = Database::fetch_row($result)) {
$md5Key = md5($row[1]);
$docsSize[$md5Key] = $row[0];
}
return array_sum($docsSize);
}
/**

Loading…
Cancel
Save