public function filedepot::getRecursiveCatIDs in filedepot 7
3 calls to filedepot::getRecursiveCatIDs()
- filedepot::deleteFolder in ./
filedepot.class.php - filedepot::getAllowableCategories in ./
filedepot.class.php - Return list of repository categories user has permission to access to be used in SQL statements
- filedepot::__construct in ./
filedepot.class.php
File
- ./
filedepot.class.php, line 418 - filedepot.class.php Main class for the Filedepot module
Class
- filedepot
- @file filedepot.class.php Main class for the Filedepot module
Code
public function getRecursiveCatIDs(&$list, $cid, $perms, $override = false, $createFolderIndex = false, $folderprefixroot = '') {
global $user;
$query = db_query("SELECT cid FROM {filedepot_categories} WHERE PID=:cid ORDER BY cid", array(
'cid' => $cid,
));
$i = 0;
$folderprefix = '';
while ($A = $query
->fetchAssoc()) {
// Check and see if this category has any sub categories - where a category record has this cid as it's parent
if (db_query("SELECT count(pid) FROM {filedepot_categories} WHERE pid=:cid", array(
'cid' => $A['cid'],
))
->fetchField() > 0) {
if ($override === TRUE or $this
->checkPermission($A['cid'], $perms)) {
$i++;
array_push($list, $A['cid']);
if ($createFolderIndex) {
if (empty($folderprefixroot)) {
$folderprefix = "{$i}";
}
else {
$folderprefix = "{$folderprefixroot}.{$i}";
}
db_delete('filedepot_folderindex')
->condition('uid', $user->uid)
->condition('cid', $A['cid'])
->execute();
$q2 = db_insert('filedepot_folderindex');
$q2
->fields(array(
'cid',
'uid',
'folderprefix',
));
$q2
->values(array(
'cid' => $A['cid'],
'uid' => $user->uid,
'folderprefix' => $folderprefix,
));
$q2
->execute();
}
$this
->getRecursiveCatIDs($list, $A['cid'], $perms, $override, $createFolderIndex, $folderprefix);
}
}
else {
if ($override === TRUE or $this
->checkPermission($A['cid'], $perms)) {
$i++;
array_push($list, $A['cid']);
if ($createFolderIndex) {
if (empty($folderprefixroot)) {
$folderprefix = "{$i}";
}
else {
$folderprefix = "{$folderprefixroot}.{$i}";
}
db_delete('filedepot_folderindex')
->condition('uid', $user->uid)
->condition('cid', $A['cid'])
->execute();
$q2 = db_insert('filedepot_folderindex');
$q2
->fields(array(
'cid',
'uid',
'folderprefix',
));
$q2
->values(array(
'cid' => $A['cid'],
'uid' => $user->uid,
'folderprefix' => $folderprefix,
));
$q2
->execute();
}
}
}
}
return $list;
}