function filedepot_updateFolderLastModified in filedepot 6
Same name and namespace in other branches
- 7 lib-common.php \filedepot_updateFolderLastModified()
4 calls to filedepot_updateFolderLastModified()
File
- ./
lib-common.php, line 150 - lib-common.php Common library of functions for the applications
Code
function filedepot_updateFolderLastModified($id) {
$last_modified_parentdate = 0;
if (db_result(db_query("SELECT cid FROM {filedepot_categories} WHERE cid=%d", $id)) > 0) {
$q1 = db_query("SELECT cid FROM {filedepot_categories} WHERE pid=%d ORDER BY folderorder ASC", $id);
while ($A = db_fetch_array($q1)) {
$last_modified_date = 0;
$q2 = db_query_range("SELECT date FROM {filedepot_files} WHERE cid=%d ORDER BY date DESC", array(
$A['cid'],
), 0, 1);
$B = db_fetch_array($q2);
if ($B['date'] > $last_modified_date) {
$last_modified_date = $date;
}
if (db_result(db_query("SELECT pid FROM {filedepot_categories} WHERE cid=%d", $A['cid'])) > 0) {
$latestdate = filedepot_updateFolderLastModified($A['cid']);
if ($latestdate > $last_modified_date) {
$last_modified_date = $latestdate;
}
}
db_query("UPDATE {filedepot_categories} SET last_modified_date=%d WHERE cid=%d", $last_modified_date, $A['cid']);
if ($last_modified_date > $last_modified_parentdate) {
$last_modified_parentdate = $last_modified_date;
}
}
db_query("UPDATE {filedepot_categories} SET last_modified_date=%d WHERE cid=%d", $last_modified_parentdate, $id);
}
$q4 = db_query("SELECT date FROM {filedepot_files} WHERE cid=%d ORDER BY date DESC", array(
$id,
), 0, 1);
$C = db_fetch_array($q4);
if ($C['date'] > $last_modified_parentdate) {
$last_modified_parentdate = $C['date'];
}
db_query("UPDATE {filedepot_categories} SET last_modified_date=%d WHERE cid=%d", $last_modified_parentdate, $id);
return $last_modified_parentdate;
}