public function getChildAmount($user = null)
{
if ($user and !$user->isAdmin()) {
$userIds = $user->getRoles();
$userIds[] = $user->getId();
$query = "select count(*) from assets a where parentId = ?\n and (select list as locate from users_workspaces_asset where userId in (" . implode(',', $userIds) . ") and LOCATE(cpath,CONCAT(a.path,a.filename))=1 ORDER BY LENGTH(cpath) DESC LIMIT 1)=1;";
} else {
$query = "SELECT COUNT(*) AS count FROM assets WHERE parentId = ?";
}
$c = $this->db->fetchOne($query, $this->model->getId());
return $c;
}